{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b9330fca-c5cb-4e8b-9668-9c4d618d697d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Overwriting my_test.py\n"
     ]
    }
   ],
   "source": [
    "%%writefile my_test.py\n",
    "# 魔法方法只能放第一行\n",
    "def Test(name):\n",
    "    print('Test',name,'success')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "bb858732-84b7-4277-93ab-d44e293e8db6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[38;5;66;03m# 魔法方法只能放第一行\u001b[39;00m\n",
       "\u001b[38;5;28;01mdef\u001b[39;00m Test(name):\n",
       "    print(\u001b[33m'Test'\u001b[39m,name,\u001b[33m'success'\u001b[39m)\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%pycat my_test.py "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "85eb5735-0e75-42bf-a1a9-19a9abaf8b40",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test Jupyter success\n"
     ]
    }
   ],
   "source": [
    "%run my_test.py\n",
    "Test('Jupyter')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c5f73bee-ebc4-42d7-bc38-be9349b4d47a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test Test import success\n"
     ]
    }
   ],
   "source": [
    "import my_test;\n",
    "my_test.Test('Test import')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1c066689-0dec-41f6-83cf-03bdc76ef59c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test import alias name success\n"
     ]
    }
   ],
   "source": [
    "from my_test import Test;\n",
    "Test('import alias name')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "6a66ef55-4b7b-4b01-9785-58b7836779d3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20.6 μs ± 176 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)\n"
     ]
    }
   ],
   "source": [
    "# 评估后面代码耗时，自动多次运行该 cell，统计平均运行时间，报告 均值和标准差。适合场景：想比较不同实现的性能、需要更精确的平均耗时测量。\n",
    "%timeit data=[i*i for i in range(1000)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "f8a41e9d-e013-4de8-bb27-9b0a78abbe7b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "504 ms ± 702 μs per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
     ]
    }
   ],
   "source": [
    "%%timeit\n",
    "# 评估整个代码块运行的时间(与单行时间写法需要多一个%号)\n",
    "import time\n",
    "time.sleep(0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "b7d048ef-fa50-45a2-9e2e-b47282c27b26",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 60 μs, sys: 3 μs, total: 63 μs\n",
      "Wall time: 68.2 μs\n"
     ]
    }
   ],
   "source": [
    "%time data = [i*i for i in range(1000)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "03ab690a-c06a-4e34-8187-7349556643da",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 675 μs, sys: 1.68 ms, total: 2.35 ms\n",
      "Wall time: 503 ms\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "# 只运行一次整个 cell，报告 一次运行的耗时（包括 CPU 时间和 Wall 时间）。适合场景： 代码运行时间比较长、不需要重复运行统计平均值的情况。\n",
    "import time\n",
    "time.sleep(0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "3fcf2ae6-b71f-440a-bade-a168694dc21b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Variable   Type        Data/Info\n",
      "--------------------------------\n",
      "Test       function    <function Test at 0x108c8aac0>\n",
      "a          int         123\n",
      "data       list        n=1000\n",
      "my_test    module      <module 'my_test' from '/<...>rojects/机器学习/my_test.py'>\n",
      "time       module      <module 'time' (built-in)>\n"
     ]
    }
   ],
   "source": [
    "a = 123\n",
    "%whos\n",
    "# 主要用来查看当前交互式环境里有哪些变量，以及它们的类型、大小和内容摘要。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "91f44d6b-6cd5-4d19-a8cb-a3fdc255c994",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/json": {
       "cell": {
        "!": "OSMagics",
        "HTML": "Other",
        "SVG": "Other",
        "bash": "Other",
        "capture": "ExecutionMagics",
        "code_wrap": "ExecutionMagics",
        "debug": "ExecutionMagics",
        "file": "Other",
        "html": "DisplayMagics",
        "javascript": "DisplayMagics",
        "js": "DisplayMagics",
        "latex": "DisplayMagics",
        "markdown": "DisplayMagics",
        "perl": "Other",
        "prun": "ExecutionMagics",
        "pypy": "Other",
        "python": "Other",
        "python2": "Other",
        "python3": "Other",
        "ruby": "Other",
        "script": "ScriptMagics",
        "sh": "Other",
        "svg": "DisplayMagics",
        "sx": "OSMagics",
        "system": "OSMagics",
        "time": "ExecutionMagics",
        "timeit": "ExecutionMagics",
        "writefile": "OSMagics"
       },
       "line": {
        "alias": "OSMagics",
        "alias_magic": "BasicMagics",
        "autoawait": "AsyncMagics",
        "autocall": "AutoMagics",
        "automagic": "AutoMagics",
        "autosave": "KernelMagics",
        "bookmark": "OSMagics",
        "cat": "Other",
        "cd": "OSMagics",
        "clear": "KernelMagics",
        "code_wrap": "ExecutionMagics",
        "colors": "BasicMagics",
        "conda": "PackagingMagics",
        "config": "ConfigMagics",
        "connect_info": "KernelMagics",
        "cp": "Other",
        "debug": "ExecutionMagics",
        "dhist": "OSMagics",
        "dirs": "OSMagics",
        "doctest_mode": "BasicMagics",
        "ed": "Other",
        "edit": "KernelMagics",
        "env": "OSMagics",
        "gui": "BasicMagics",
        "hist": "Other",
        "history": "HistoryMagics",
        "killbgscripts": "ScriptMagics",
        "ldir": "Other",
        "less": "KernelMagics",
        "lf": "Other",
        "lk": "Other",
        "ll": "Other",
        "load": "CodeMagics",
        "load_ext": "ExtensionMagics",
        "loadpy": "CodeMagics",
        "logoff": "LoggingMagics",
        "logon": "LoggingMagics",
        "logstart": "LoggingMagics",
        "logstate": "LoggingMagics",
        "logstop": "LoggingMagics",
        "ls": "Other",
        "lsmagic": "BasicMagics",
        "lx": "Other",
        "macro": "ExecutionMagics",
        "magic": "BasicMagics",
        "mamba": "PackagingMagics",
        "man": "KernelMagics",
        "matplotlib": "PylabMagics",
        "micromamba": "PackagingMagics",
        "mkdir": "Other",
        "more": "KernelMagics",
        "mv": "Other",
        "notebook": "BasicMagics",
        "page": "BasicMagics",
        "pastebin": "CodeMagics",
        "pdb": "ExecutionMagics",
        "pdef": "NamespaceMagics",
        "pdoc": "NamespaceMagics",
        "pfile": "NamespaceMagics",
        "pinfo": "NamespaceMagics",
        "pinfo2": "NamespaceMagics",
        "pip": "PackagingMagics",
        "popd": "OSMagics",
        "pprint": "BasicMagics",
        "precision": "BasicMagics",
        "prun": "ExecutionMagics",
        "psearch": "NamespaceMagics",
        "psource": "NamespaceMagics",
        "pushd": "OSMagics",
        "pwd": "OSMagics",
        "pycat": "OSMagics",
        "pylab": "PylabMagics",
        "qtconsole": "KernelMagics",
        "quickref": "BasicMagics",
        "recall": "HistoryMagics",
        "rehashx": "OSMagics",
        "reload_ext": "ExtensionMagics",
        "rep": "Other",
        "rerun": "HistoryMagics",
        "reset": "NamespaceMagics",
        "reset_selective": "NamespaceMagics",
        "rm": "Other",
        "rmdir": "Other",
        "run": "ExecutionMagics",
        "save": "CodeMagics",
        "sc": "OSMagics",
        "set_env": "OSMagics",
        "store": "StoreMagics",
        "sx": "OSMagics",
        "system": "OSMagics",
        "tb": "ExecutionMagics",
        "time": "ExecutionMagics",
        "timeit": "ExecutionMagics",
        "unalias": "OSMagics",
        "unload_ext": "ExtensionMagics",
        "uv": "PackagingMagics",
        "who": "NamespaceMagics",
        "who_ls": "NamespaceMagics",
        "whos": "NamespaceMagics",
        "xdel": "NamespaceMagics",
        "xmode": "BasicMagics"
       }
      },
      "text/plain": [
       "Available line magics:\n",
       "%alias  %alias_magic  %autoawait  %autocall  %automagic  %autosave  %bookmark  %cat  %cd  %clear  %code_wrap  %colors  %conda  %config  %connect_info  %cp  %debug  %dhist  %dirs  %doctest_mode  %ed  %edit  %env  %gui  %hist  %history  %killbgscripts  %ldir  %less  %lf  %lk  %ll  %load  %load_ext  %loadpy  %logoff  %logon  %logstart  %logstate  %logstop  %ls  %lsmagic  %lx  %macro  %magic  %mamba  %man  %matplotlib  %micromamba  %mkdir  %more  %mv  %notebook  %page  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2  %pip  %popd  %pprint  %precision  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  %qtconsole  %quickref  %recall  %rehashx  %reload_ext  %rep  %rerun  %reset  %reset_selective  %rm  %rmdir  %run  %save  %sc  %set_env  %store  %sx  %system  %tb  %time  %timeit  %unalias  %unload_ext  %uv  %who  %who_ls  %whos  %xdel  %xmode\n",
       "\n",
       "Available cell magics:\n",
       "%%!  %%HTML  %%SVG  %%bash  %%capture  %%code_wrap  %%debug  %%file  %%html  %%javascript  %%js  %%latex  %%markdown  %%perl  %%prun  %%pypy  %%python  %%python2  %%python3  %%ruby  %%script  %%sh  %%svg  %%sx  %%system  %%time  %%timeit  %%writefile\n",
       "\n",
       "Automagic is ON, % prefix IS NOT needed for line magics."
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 用来列出当前可用的所有 magic/魔法 命令\n",
    "%lsmagic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "39b5d917-aa3d-47ba-a406-ed47d697d078",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\n",
       "IPython's 'magic' functions\n",
       "===========================\n",
       "\n",
       "The magic function system provides a series of functions which allow you to\n",
       "control the behavior of IPython itself, plus a lot of system-type\n",
       "features. There are two kinds of magics, line-oriented and cell-oriented.\n",
       "\n",
       "Line magics are prefixed with the % character and work much like OS\n",
       "command-line calls: they get as an argument the rest of the line, where\n",
       "arguments are passed without parentheses or quotes.  For example, this will\n",
       "time the given statement::\n",
       "\n",
       "        %timeit range(1000)\n",
       "\n",
       "Cell magics are prefixed with a double %%, and they are functions that get as\n",
       "an argument not only the rest of the line, but also the lines below it in a\n",
       "separate argument.  These magics are called with two arguments: the rest of the\n",
       "call line and the body of the cell, consisting of the lines below the first.\n",
       "For example::\n",
       "\n",
       "        %%timeit x = numpy.random.randn((100, 100))\n",
       "        numpy.linalg.svd(x)\n",
       "\n",
       "will time the execution of the numpy svd routine, running the assignment of x\n",
       "as part of the setup phase, which is not timed.\n",
       "\n",
       "In a line-oriented client (the terminal or Qt console IPython), starting a new\n",
       "input with %% will automatically enter cell mode, and IPython will continue\n",
       "reading input until a blank line is given.  In the notebook, simply type the\n",
       "whole cell as one entity, but keep in mind that the %% escape can only be at\n",
       "the very start of the cell.\n",
       "\n",
       "NOTE: If you have 'automagic' enabled (via the command line option or with the\n",
       "%automagic function), you don't need to type in the % explicitly for line\n",
       "magics; cell magics always require an explicit '%%' escape.  By default,\n",
       "IPython ships with automagic on, so you should only rarely need the % escape.\n",
       "\n",
       "Example: typing '%cd mydir' (without the quotes) changes your working directory\n",
       "to 'mydir', if it exists.\n",
       "\n",
       "For a list of the available magic functions, use %lsmagic. For a description\n",
       "of any of them, type %magic_name?, e.g. '%cd?'.\n",
       "\n",
       "Currently the magic system has the following functions:\n",
       "%alias:\n",
       "    Define an alias for a system command.\n",
       "    \n",
       "    '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'\n",
       "    \n",
       "    Then, typing 'alias_name params' will execute the system command 'cmd\n",
       "    params' (from your underlying operating system).\n",
       "    \n",
       "    Aliases have lower precedence than magic functions and Python normal\n",
       "    variables, so if 'foo' is both a Python variable and an alias, the\n",
       "    alias can not be executed until 'del foo' removes the Python variable.\n",
       "    \n",
       "    You can use the %l specifier in an alias definition to represent the\n",
       "    whole line when the alias is called.  For example::\n",
       "    \n",
       "      In [2]: alias bracket echo \"Input in brackets: <%l>\"\n",
       "      In [3]: bracket hello world\n",
       "      Input in brackets: <hello world>\n",
       "    \n",
       "    You can also define aliases with parameters using %s specifiers (one\n",
       "    per parameter)::\n",
       "    \n",
       "      In [1]: alias parts echo first %s second %s\n",
       "      In [2]: %parts A B\n",
       "      first A second B\n",
       "      In [3]: %parts A\n",
       "      Incorrect number of arguments: 2 expected.\n",
       "      parts is an alias to: 'echo first %s second %s'\n",
       "    \n",
       "    Note that %l and %s are mutually exclusive.  You can only use one or\n",
       "    the other in your aliases.\n",
       "    \n",
       "    Aliases expand Python variables just like system calls using ! or !!\n",
       "    do: all expressions prefixed with '$' get expanded.  For details of\n",
       "    the semantic rules, see PEP-215:\n",
       "    https://peps.python.org/pep-0215/.  This is the library used by\n",
       "    IPython for variable expansion.  If you want to access a true shell\n",
       "    variable, an extra $ is necessary to prevent its expansion by\n",
       "    IPython::\n",
       "    \n",
       "      In [6]: alias show echo\n",
       "      In [7]: PATH='A Python string'\n",
       "      In [8]: show $PATH\n",
       "      A Python string\n",
       "      In [9]: show $$PATH\n",
       "      /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...\n",
       "    \n",
       "    You can use the alias facility to access all of $PATH.  See the %rehashx\n",
       "    function, which automatically creates aliases for the contents of your\n",
       "    $PATH.\n",
       "    \n",
       "    If called with no parameters, %alias prints the current alias table\n",
       "    for your system.  For posix systems, the default aliases are 'cat',\n",
       "    'cp', 'mv', 'rm', 'rmdir', and 'mkdir', and other platform-specific\n",
       "    aliases are added.  For windows-based systems, the default aliases are\n",
       "    'copy', 'ddir', 'echo', 'ls', 'ldir', 'mkdir', 'ren', and 'rmdir'.\n",
       "    \n",
       "    You can see the definition of alias by adding a question mark in the\n",
       "    end::\n",
       "    \n",
       "      In [1]: cat?\n",
       "      Repr: <alias cat for 'cat'>\n",
       "%alias_magic:\n",
       "    ::\n",
       "    \n",
       "      %alias_magic [-l] [-c] [-p PARAMS] name target\n",
       "    \n",
       "    Create an alias for an existing line or cell magic.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "      In [1]: %alias_magic t timeit\n",
       "      Created `%t` as an alias for `%timeit`.\n",
       "      Created `%%t` as an alias for `%%timeit`.\n",
       "    \n",
       "      In [2]: %t -n1 pass\n",
       "      107 ns ± 43.6 ns per loop (mean ± std. dev. of 7 runs, 1 loop each)\n",
       "    \n",
       "      In [3]: %%t -n1\n",
       "         ...: pass\n",
       "         ...:\n",
       "      107 ns ± 58.3 ns per loop (mean ± std. dev. of 7 runs, 1 loop each)\n",
       "    \n",
       "      In [4]: %alias_magic --cell whereami pwd\n",
       "      UsageError: Cell magic function `%%pwd` not found.\n",
       "      In [5]: %alias_magic --line whereami pwd\n",
       "      Created `%whereami` as an alias for `%pwd`.\n",
       "    \n",
       "      In [6]: %whereami\n",
       "      Out[6]: '/home/testuser'\n",
       "    \n",
       "      In [7]: %alias_magic h history -p \"-l 30\" --line\n",
       "      Created `%h` as an alias for `%history -l 30`.\n",
       "    \n",
       "    positional arguments:\n",
       "      name                  Name of the magic to be created.\n",
       "      target                Name of the existing line or cell magic.\n",
       "    \n",
       "    options:\n",
       "      -l, --line            Create a line magic alias.\n",
       "      -c, --cell            Create a cell magic alias.\n",
       "      -p PARAMS, --params PARAMS\n",
       "                            Parameters passed to the magic function.\n",
       "%autoawait:\n",
       "    \n",
       "    Allow to change the status of the autoawait option.\n",
       "    \n",
       "    This allow you to set a specific asynchronous code runner.\n",
       "    \n",
       "    If no value is passed, print the currently used asynchronous integration\n",
       "    and whether it is activated.\n",
       "    \n",
       "    It can take a number of value evaluated in the following order:\n",
       "    \n",
       "    - False/false/off deactivate autoawait integration\n",
       "    - True/true/on activate autoawait integration using configured default\n",
       "      loop\n",
       "    - asyncio/curio/trio activate autoawait integration and use integration\n",
       "      with said library.\n",
       "    \n",
       "    - `sync` turn on the pseudo-sync integration (mostly used for\n",
       "      `IPython.embed()` which does not run IPython with a real eventloop and\n",
       "      deactivate running asynchronous code. Turning on Asynchronous code with\n",
       "      the pseudo sync loop is undefined behavior and may lead IPython to crash.\n",
       "    \n",
       "    If the passed parameter does not match any of the above and is a python\n",
       "    identifier, get said object from user namespace and set it as the\n",
       "    runner, and activate autoawait.\n",
       "    \n",
       "    If the object is a fully qualified object name, attempt to import it and\n",
       "    set it as the runner, and activate autoawait.\n",
       "    \n",
       "    The exact behavior of autoawait is experimental and subject to change\n",
       "    across version of IPython and Python.\n",
       "%autocall:\n",
       "    Make functions callable without having to type parentheses.\n",
       "    \n",
       "    Usage:\n",
       "    \n",
       "       %autocall [mode]\n",
       "    \n",
       "    The mode can be one of: 0->Off, 1->Smart, 2->Full.  If not given, the\n",
       "    value is toggled on and off (remembering the previous state).\n",
       "    \n",
       "    In more detail, these values mean:\n",
       "    \n",
       "    0 -> fully disabled\n",
       "    \n",
       "    1 -> active, but do not apply if there are no arguments on the line.\n",
       "    \n",
       "    In this mode, you get::\n",
       "    \n",
       "      In [1]: callable\n",
       "      Out[1]: <built-in function callable>\n",
       "    \n",
       "      In [2]: callable 'hello'\n",
       "      ------> callable('hello')\n",
       "      Out[2]: False\n",
       "    \n",
       "    2 -> Active always.  Even if no arguments are present, the callable\n",
       "    object is called::\n",
       "    \n",
       "      In [2]: float\n",
       "      ------> float()\n",
       "      Out[2]: 0.0\n",
       "    \n",
       "    Note that even with autocall off, you can still use '/' at the start of\n",
       "    a line to treat the first argument on the command line as a function\n",
       "    and add parentheses to it::\n",
       "    \n",
       "      In [8]: /str 43\n",
       "      ------> str(43)\n",
       "      Out[8]: '43'\n",
       "    \n",
       "    # all-random (note for auto-testing)\n",
       "%automagic:\n",
       "    Make magic functions callable without having to type the initial %.\n",
       "    \n",
       "    Without arguments toggles on/off (when off, you must call it as\n",
       "    %automagic, of course).  With arguments it sets the value, and you can\n",
       "    use any of (case insensitive):\n",
       "    \n",
       "     - on, 1, True: to activate\n",
       "    \n",
       "     - off, 0, False: to deactivate.\n",
       "    \n",
       "    Note that magic functions have lowest priority, so if there's a\n",
       "    variable whose name collides with that of a magic fn, automagic won't\n",
       "    work for that function (you get the variable instead). However, if you\n",
       "    delete the variable (del var), the previously shadowed magic function\n",
       "    becomes visible to automagic again.\n",
       "%autosave:\n",
       "    Set the autosave interval in the notebook (in seconds).\n",
       "    \n",
       "    The default value is 120, or two minutes.\n",
       "    ``%autosave 0`` will disable autosave.\n",
       "    \n",
       "    This magic only has an effect when called from the notebook interface.\n",
       "    It has no effect when called in a startup file.\n",
       "%bookmark:\n",
       "    Manage IPython's bookmark system.\n",
       "    \n",
       "    %bookmark <name>       - set bookmark to current dir\n",
       "    %bookmark <name> <dir> - set bookmark to <dir>\n",
       "    %bookmark -l           - list all bookmarks\n",
       "    %bookmark -d <name>    - remove bookmark\n",
       "    %bookmark -r           - remove all bookmarks\n",
       "    \n",
       "    You can later on access a bookmarked folder with::\n",
       "    \n",
       "      %cd -b <name>\n",
       "    \n",
       "    or simply '%cd <name>' if there is no directory called <name> AND\n",
       "    there is such a bookmark defined.\n",
       "    \n",
       "    Your bookmarks persist through IPython sessions, but they are\n",
       "    associated with each profile.\n",
       "%cat:\n",
       "    Alias for `!cat`\n",
       "%cd:\n",
       "    Change the current working directory.\n",
       "    \n",
       "    This command automatically maintains an internal list of directories\n",
       "    you visit during your IPython session, in the variable ``_dh``. The\n",
       "    command :magic:`%dhist` shows this history nicely formatted. You can\n",
       "    also do ``cd -<tab>`` to see directory history conveniently.\n",
       "    Usage:\n",
       "    \n",
       "      - ``cd 'dir'``: changes to directory 'dir'.\n",
       "      - ``cd -``: changes to the last visited directory.\n",
       "      - ``cd -<n>``: changes to the n-th directory in the directory history.\n",
       "      - ``cd --foo``: change to directory that matches 'foo' in history\n",
       "      - ``cd -b <bookmark_name>``: jump to a bookmark set by %bookmark\n",
       "      - Hitting a tab key after ``cd -b`` allows you to tab-complete\n",
       "        bookmark names.\n",
       "    \n",
       "      .. note::\n",
       "        ``cd <bookmark_name>`` is enough if there is no directory\n",
       "        ``<bookmark_name>``, but a bookmark with the name exists.\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "    -q               Be quiet. Do not print the working directory after the\n",
       "                      cd command is executed. By default IPython's cd\n",
       "                      command does print this directory, since the default\n",
       "                      prompts do not display path information.\n",
       "    \n",
       "    .. note::\n",
       "       Note that ``!cd`` doesn't work for this purpose because the shell\n",
       "       where ``!command`` runs is immediately discarded after executing\n",
       "       'command'.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "      In [10]: cd parent/child\n",
       "      /home/tsuser/parent/child\n",
       "%clear:\n",
       "    Clear the terminal.\n",
       "%code_wrap:\n",
       "    ::\n",
       "    \n",
       "      %code_wrap [--remove] [--list] [--list-all] [name]\n",
       "    \n",
       "    Simple magic to quickly define a code transformer for all IPython's future input.\n",
       "    \n",
       "    ``__code__`` and ``__ret__`` are special variable that represent the code to run\n",
       "    and the value of the last expression of ``__code__`` respectively.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    \n",
       "    .. ipython::\n",
       "    \n",
       "        In [1]: %%code_wrap before_after\n",
       "           ...: print('before')\n",
       "           ...: __code__\n",
       "           ...: print('after')\n",
       "           ...: __ret__\n",
       "    \n",
       "        In [2]: 1\n",
       "        before\n",
       "        after\n",
       "        Out[2]: 1\n",
       "    \n",
       "        In [3]: %code_wrap --list\n",
       "        before_after\n",
       "    \n",
       "        In [4]: %code_wrap --list-all\n",
       "        before_after :\n",
       "            print('before')\n",
       "            __code__\n",
       "            print('after')\n",
       "            __ret__\n",
       "    \n",
       "        In [5]: %code_wrap --remove before_after\n",
       "    \n",
       "    positional arguments:\n",
       "      name\n",
       "    \n",
       "    options:\n",
       "      --remove    remove the current transformer\n",
       "      --list      list existing transformers name\n",
       "      --list-all  list existing transformers name and code template\n",
       "%colors:\n",
       "    Switch color scheme/theme globally for IPython\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    To get a plain black and white terminal::\n",
       "    \n",
       "      %colors nocolor\n",
       "%conda:\n",
       "    Run the conda package manager within the current kernel.\n",
       "    \n",
       "    Usage:\n",
       "      %conda install [pkgs]\n",
       "%config:\n",
       "    configure IPython\n",
       "    \n",
       "        %config Class[.trait=value]\n",
       "    \n",
       "    This magic exposes most of the IPython config system. Any\n",
       "    Configurable class should be able to be configured with the simple\n",
       "    line::\n",
       "    \n",
       "        %config Class.trait=value\n",
       "    \n",
       "    Where `value` will be resolved in the user's namespace, if it is an\n",
       "    expression or variable name.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    \n",
       "    To see what classes are available for config, pass no arguments::\n",
       "    \n",
       "        In [1]: %config\n",
       "        Available objects for config:\n",
       "            AliasManager\n",
       "            DisplayFormatter\n",
       "            HistoryManager\n",
       "            IPCompleter\n",
       "            LoggingMagics\n",
       "            MagicsManager\n",
       "            OSMagics\n",
       "            PrefilterManager\n",
       "            ScriptMagics\n",
       "            TerminalInteractiveShell\n",
       "    \n",
       "    To view what is configurable on a given class, just pass the class\n",
       "    name::\n",
       "    \n",
       "        In [2]: %config LoggingMagics\n",
       "        LoggingMagics(Magics) options\n",
       "        ---------------------------\n",
       "        LoggingMagics.quiet=<Bool>\n",
       "            Suppress output of log state when logging is enabled\n",
       "            Current: False\n",
       "    \n",
       "    but the real use is in setting values::\n",
       "    \n",
       "        In [3]: %config LoggingMagics.quiet = True\n",
       "    \n",
       "    and these values are read from the user_ns if they are variables::\n",
       "    \n",
       "        In [4]: feeling_quiet=False\n",
       "    \n",
       "        In [5]: %config LoggingMagics.quiet = feeling_quiet\n",
       "%connect_info:\n",
       "    Print information for connecting other clients to this kernel\n",
       "    \n",
       "    It will print the contents of this session's connection file, as well as\n",
       "    shortcuts for local clients.\n",
       "    \n",
       "    In the simplest case, when called from the most recently launched kernel,\n",
       "    secondary clients can be connected, simply with:\n",
       "    \n",
       "    $> jupyter <app> --existing\n",
       "%cp:\n",
       "    Alias for `!cp`\n",
       "%debug:\n",
       "    ::\n",
       "    \n",
       "      %debug [--breakpoint FILE:LINE] [statement ...]\n",
       "    \n",
       "    Activate the interactive debugger.\n",
       "    \n",
       "    This magic command support two ways of activating debugger.\n",
       "    One is to activate debugger before executing code.  This way, you\n",
       "    can set a break point, to step through the code from the point.\n",
       "    You can use this mode by giving statements to execute and optionally\n",
       "    a breakpoint.\n",
       "    \n",
       "    The other one is to activate debugger in post-mortem mode.  You can\n",
       "    activate this mode simply running %debug without any argument.\n",
       "    If an exception has just occurred, this lets you inspect its stack\n",
       "    frames interactively.  Note that this will always work only on the last\n",
       "    traceback that occurred, so you must call this quickly after an\n",
       "    exception that you wish to inspect has fired, because if another one\n",
       "    occurs, it clobbers the previous one.\n",
       "    \n",
       "    If you want IPython to automatically do this on every exception, see\n",
       "    the %pdb magic for more details.\n",
       "    \n",
       "    .. versionchanged:: 7.3\n",
       "        When running code, user variables are no longer expanded,\n",
       "        the magic line is always left unmodified.\n",
       "    \n",
       "    positional arguments:\n",
       "      statement             Code to run in debugger. You can omit this in cell magic mode.\n",
       "    \n",
       "    options:\n",
       "      --breakpoint <FILE:LINE>, -b <FILE:LINE>\n",
       "                            Set break point at LINE in FILE.\n",
       "%dhist:\n",
       "    Print your history of visited directories.\n",
       "    \n",
       "    %dhist       -> print full history\n",
       "    %dhist n     -> print last n entries only\n",
       "    %dhist n1 n2 -> print entries between n1 and n2 (n2 not included)\n",
       "    \n",
       "    This history is automatically maintained by the %cd command, and\n",
       "    always available as the global list variable _dh. You can use %cd -<n>\n",
       "    to go to directory number <n>.\n",
       "    \n",
       "    Note that most of time, you should view directory history by entering\n",
       "    cd -<TAB>.\n",
       "%dirs:\n",
       "    Return the current directory stack.\n",
       "%doctest_mode:\n",
       "    Toggle doctest mode on and off.\n",
       "    \n",
       "    This mode is intended to make IPython behave as much as possible like a\n",
       "    plain Python shell, from the perspective of how its prompts, exceptions\n",
       "    and output look.  This makes it easy to copy and paste parts of a\n",
       "    session into doctests.  It does so by:\n",
       "    \n",
       "    - Changing the prompts to the classic ``>>>`` ones.\n",
       "    - Changing the exception reporting mode to 'Plain'.\n",
       "    - Disabling pretty-printing of output.\n",
       "    \n",
       "    Note that IPython also supports the pasting of code snippets that have\n",
       "    leading '>>>' and '...' prompts in them.  This means that you can paste\n",
       "    doctests from files or docstrings (even if they have leading\n",
       "    whitespace), and the code will execute correctly.  You can then use\n",
       "    '%history -t' to see the translated history; this will give you the\n",
       "    input after removal of all the leading prompts and whitespace, which\n",
       "    can be pasted back into an editor.\n",
       "    \n",
       "    With these features, you can switch into this mode easily whenever you\n",
       "    need to do testing and changes to doctests, without having to leave\n",
       "    your existing IPython session.\n",
       "%ed:\n",
       "    Alias for `%edit`.\n",
       "%edit:\n",
       "    Bring up an editor and execute the resulting code.\n",
       "    \n",
       "    Usage:\n",
       "      %edit [options] [args]\n",
       "    \n",
       "    %edit runs an external text editor. You will need to set the command for\n",
       "    this editor via the ``TerminalInteractiveShell.editor`` option in your\n",
       "    configuration file before it will work.\n",
       "    \n",
       "    This command allows you to conveniently edit multi-line code right in\n",
       "    your IPython session.\n",
       "    \n",
       "    If called without arguments, %edit opens up an empty editor with a\n",
       "    temporary file and will execute the contents of this file when you\n",
       "    close it (don't forget to save it!).\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "    -n <number>\n",
       "      Open the editor at a specified line number. By default, the IPython\n",
       "      editor hook uses the unix syntax 'editor +N filename', but you can\n",
       "      configure this by providing your own modified hook if your favorite\n",
       "      editor supports line-number specifications with a different syntax.\n",
       "    \n",
       "    -p\n",
       "      Call the editor with the same data as the previous time it was used,\n",
       "      regardless of how long ago (in your current session) it was.\n",
       "    \n",
       "    -r\n",
       "      Use 'raw' input. This option only applies to input taken from the\n",
       "      user's history.  By default, the 'processed' history is used, so that\n",
       "      magics are loaded in their transformed version to valid Python.  If\n",
       "      this option is given, the raw input as typed as the command line is\n",
       "      used instead.  When you exit the editor, it will be executed by\n",
       "      IPython's own processor.\n",
       "    \n",
       "    Arguments:\n",
       "    \n",
       "    If arguments are given, the following possibilities exist:\n",
       "    \n",
       "    - The arguments are numbers or pairs of colon-separated numbers (like\n",
       "      1 4:8 9). These are interpreted as lines of previous input to be\n",
       "      loaded into the editor. The syntax is the same of the %macro command.\n",
       "    \n",
       "    - If the argument doesn't start with a number, it is evaluated as a\n",
       "      variable and its contents loaded into the editor. You can thus edit\n",
       "      any string which contains python code (including the result of\n",
       "      previous edits).\n",
       "    \n",
       "    - If the argument is the name of an object (other than a string),\n",
       "      IPython will try to locate the file where it was defined and open the\n",
       "      editor at the point where it is defined. You can use ``%edit function``\n",
       "      to load an editor exactly at the point where 'function' is defined,\n",
       "      edit it and have the file be executed automatically.\n",
       "    \n",
       "      If the object is a macro (see %macro for details), this opens up your\n",
       "      specified editor with a temporary file containing the macro's data.\n",
       "      Upon exit, the macro is reloaded with the contents of the file.\n",
       "    \n",
       "      Note: opening at an exact line is only supported under Unix, and some\n",
       "      editors (like kedit and gedit up to Gnome 2.8) do not understand the\n",
       "      '+NUMBER' parameter necessary for this feature. Good editors like\n",
       "      (X)Emacs, vi, jed, pico and joe all do.\n",
       "    \n",
       "    - If the argument is not found as a variable, IPython will look for a\n",
       "      file with that name (adding .py if necessary) and load it into the\n",
       "      editor. It will execute its contents with execfile() when you exit,\n",
       "      loading any code in the file into your interactive namespace.\n",
       "    \n",
       "    Unlike in the terminal, this is designed to use a GUI editor, and we do\n",
       "    not know when it has closed. So the file you edit will not be\n",
       "    automatically executed or printed.\n",
       "    \n",
       "    Note that %edit is also available through the alias %ed.\n",
       "%env:\n",
       "    Get, set, or list environment variables.\n",
       "    \n",
       "    Usage:\n",
       "    \n",
       "      :``%env``: lists all environment variables/values\n",
       "      :``%env var``: get value for var\n",
       "      :``%env var val``: set value for var\n",
       "      :``%env var=val``: set value for var\n",
       "      :``%env var=$val``: set value for var, using python expansion if possible\n",
       "%gui:\n",
       "    Enable or disable IPython GUI event loop integration.\n",
       "    \n",
       "    %gui [GUINAME]\n",
       "    \n",
       "    This magic replaces IPython's threaded shells that were activated\n",
       "    using the (pylab/wthread/etc.) command line flags.  GUI toolkits\n",
       "    can now be enabled at runtime and keyboard\n",
       "    interrupts should work without any problems.  The following toolkits\n",
       "    are supported:  wxPython, PyQt4, PyGTK, Tk and Cocoa (OSX)::\n",
       "    \n",
       "        %gui wx      # enable wxPython event loop integration\n",
       "        %gui qt      # enable PyQt/PySide event loop integration\n",
       "                     # with the latest version available.\n",
       "        %gui qt6     # enable PyQt6/PySide6 event loop integration\n",
       "        %gui qt5     # enable PyQt5/PySide2 event loop integration\n",
       "        %gui gtk     # enable PyGTK event loop integration\n",
       "        %gui gtk3    # enable Gtk3 event loop integration\n",
       "        %gui gtk4    # enable Gtk4 event loop integration\n",
       "        %gui tk      # enable Tk event loop integration\n",
       "        %gui osx     # enable Cocoa event loop integration\n",
       "                     # (requires %matplotlib 1.1)\n",
       "        %gui         # disable all event loop integration\n",
       "    \n",
       "    WARNING:  after any of these has been called you can simply create\n",
       "    an application object, but DO NOT start the event loop yourself, as\n",
       "    we have already handled that.\n",
       "%hist:\n",
       "    Alias for `%history`.\n",
       "%history:\n",
       "    ::\n",
       "    \n",
       "      %history [-n] [-o] [-p] [-t] [-f FILENAME] [-g [PATTERN ...]] [-l [LIMIT]] [-u] [range ...]\n",
       "    \n",
       "    Print input history (_i<n> variables), with most recent last.\n",
       "    \n",
       "    By default, input history is printed without line numbers so it can be\n",
       "    directly pasted into an editor. Use -n to show them.\n",
       "    \n",
       "    By default, all input history from the current session is displayed.\n",
       "    Ranges of history can be indicated using the syntax:\n",
       "    \n",
       "    ``4``\n",
       "        Line 4, current session\n",
       "    ``4-6``\n",
       "        Lines 4-6, current session\n",
       "    ``243/1-5``\n",
       "        Lines 1-5, session 243\n",
       "    ``~2/7``\n",
       "        Line 7, session 2 before current\n",
       "    ``~8/1-~6/5``\n",
       "        From the first line of 8 sessions ago, to the fifth line of 6\n",
       "        sessions ago.\n",
       "    \n",
       "    Multiple ranges can be entered, separated by spaces\n",
       "    \n",
       "    The same syntax is used by %macro, %save, %edit, %rerun\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "      In [6]: %history -n 4-6\n",
       "      4:a = 12\n",
       "      5:print(a**2)\n",
       "      6:%history -n 4-6\n",
       "    \n",
       "    positional arguments:\n",
       "      range\n",
       "    \n",
       "    options:\n",
       "      -n                  print line numbers for each input. This feature is only available if numbered prompts are in use.\n",
       "      -o                  also print outputs for each input.\n",
       "      -p                  print classic '>>>' python prompts before each input. This is useful for making documentation, and in conjunction with\n",
       "                          -o, for producing doctest-ready output.\n",
       "      -t                  print the 'translated' history, as IPython understands it. IPython filters your input and converts it all into valid\n",
       "                          Python source before executing it (things like magics or aliases are turned into function calls, for example). With\n",
       "                          this option, you'll see the native history instead of the user-entered version: '%cd /' will be seen as\n",
       "                          'get_ipython().run_line_magic(\"cd\", \"/\")' instead of '%cd /'.\n",
       "      -f FILENAME         FILENAME: instead of printing the output to the screen, redirect it to the given file. The file is always overwritten,\n",
       "                          though *when it can*, IPython asks for confirmation first. In particular, running the command 'history -f FILENAME'\n",
       "                          from the IPython Notebook interface will replace FILENAME even if it already exists *without* confirmation.\n",
       "      -g <[PATTERN ...]>  treat the arg as a glob pattern to search for in (full) history. This includes the saved history (almost all commands\n",
       "                          ever written). The pattern may contain '?' to match one unknown character and '*' to match any number of unknown\n",
       "                          characters. Use '%hist -g' to show full saved history (may be very long).\n",
       "      -l <[LIMIT]>        get the last n lines from all sessions. Specify n as a single arg, or the default is the last 10 lines.\n",
       "      -u                  when searching history using `-g`, show only unique history.\n",
       "%killbgscripts:\n",
       "    Kill all BG processes started by %%script and its family.\n",
       "%ldir:\n",
       "    Alias for `!ls -F -G -l %l | grep /$`\n",
       "%less:\n",
       "    Show a file through the pager.\n",
       "    \n",
       "    Files ending in .py are syntax-highlighted.\n",
       "%lf:\n",
       "    Alias for `!ls -F -l -G %l | grep ^-`\n",
       "%lk:\n",
       "    Alias for `!ls -F -l -G %l | grep ^l`\n",
       "%ll:\n",
       "    Alias for `!ls -F -l -G`\n",
       "%load:\n",
       "    Load code into the current frontend.\n",
       "    \n",
       "    Usage:\n",
       "      %load [options] source\n",
       "    \n",
       "      where source can be a filename, URL, input history range, macro, or\n",
       "      element in the user namespace\n",
       "    \n",
       "    If no arguments are given, loads the history of this session up to this\n",
       "    point.\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "      -r <lines>: Specify lines or ranges of lines to load from the source.\n",
       "      Ranges could be specified as x-y (x..y) or in python-style x:y \n",
       "      (x..(y-1)). Both limits x and y can be left blank (meaning the \n",
       "      beginning and end of the file, respectively).\n",
       "    \n",
       "      -s <symbols>: Specify function or classes to load from python source. \n",
       "    \n",
       "      -y : Don't ask confirmation for loading source above 200 000 characters.\n",
       "    \n",
       "      -n : Include the user's namespace when searching for source code.\n",
       "    \n",
       "    This magic command can either take a local filename, a URL, an history\n",
       "    range (see %history) or a macro as argument, it will prompt for\n",
       "    confirmation before loading source with more than 200 000 characters, unless\n",
       "    -y flag is passed or if the frontend does not support raw_input::\n",
       "    \n",
       "    %load\n",
       "    %load myscript.py\n",
       "    %load 7-27\n",
       "    %load myMacro\n",
       "    %load http://www.example.com/myscript.py\n",
       "    %load -r 5-10 myscript.py\n",
       "    %load -r 10-20,30,40: foo.py\n",
       "    %load -s MyClass,wonder_function myscript.py\n",
       "    %load -n MyClass\n",
       "    %load -n my_module.wonder_function\n",
       "%load_ext:\n",
       "    Load an IPython extension by its module name.\n",
       "%loadpy:\n",
       "    Alias of `%load`\n",
       "    \n",
       "    `%loadpy` has gained some flexibility and dropped the requirement of a `.py`\n",
       "    extension. So it has been renamed simply into %load. You can look at\n",
       "    `%load`'s docstring for more info.\n",
       "%logoff:\n",
       "    Temporarily stop logging.\n",
       "    \n",
       "    You must have previously started logging.\n",
       "%logon:\n",
       "    Restart logging.\n",
       "    \n",
       "    This function is for restarting logging which you've temporarily\n",
       "    stopped with %logoff. For starting logging for the first time, you\n",
       "    must use the %logstart function, which allows you to specify an\n",
       "    optional log filename.\n",
       "%logstart:\n",
       "    Start logging anywhere in a session.\n",
       "    \n",
       "    %logstart [-o|-r|-t|-q] [log_name [log_mode]]\n",
       "    \n",
       "    If no name is given, it defaults to a file named 'ipython_log.py' in your\n",
       "    current directory, in 'rotate' mode (see below).\n",
       "    \n",
       "    '%logstart name' saves to file 'name' in 'backup' mode.  It saves your\n",
       "    history up to that point and then continues logging.\n",
       "    \n",
       "    %logstart takes a second optional parameter: logging mode. This can be one\n",
       "    of (note that the modes are given unquoted):\n",
       "    \n",
       "    append\n",
       "        Keep logging at the end of any existing file.\n",
       "    \n",
       "    backup\n",
       "        Rename any existing file to name~ and start name.\n",
       "    \n",
       "    global\n",
       "        Append to  a single logfile in your home directory.\n",
       "    \n",
       "    over\n",
       "        Overwrite any existing log.\n",
       "    \n",
       "    rotate\n",
       "        Create rotating logs: name.1~, name.2~, etc.\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "      -o\n",
       "        log also IPython's output. In this mode, all commands which\n",
       "        generate an Out[NN] prompt are recorded to the logfile, right after\n",
       "        their corresponding input line. The output lines are always\n",
       "        prepended with a '#[Out]# ' marker, so that the log remains valid\n",
       "        Python code.\n",
       "    \n",
       "      Since this marker is always the same, filtering only the output from\n",
       "      a log is very easy, using for example a simple awk call::\n",
       "    \n",
       "        awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py\n",
       "    \n",
       "      -r\n",
       "        log 'raw' input.  Normally, IPython's logs contain the processed\n",
       "        input, so that user lines are logged in their final form, converted\n",
       "        into valid Python.  For example, %Exit is logged as\n",
       "        _ip.run_line_magic(\"Exit\").  If the -r flag is given, all input is logged\n",
       "        exactly as typed, with no transformations applied.\n",
       "    \n",
       "      -t\n",
       "        put timestamps before each input line logged (these are put in\n",
       "        comments).\n",
       "    \n",
       "      -q\n",
       "        suppress output of logstate message when logging is invoked\n",
       "%logstate:\n",
       "    Print the status of the logging system.\n",
       "%logstop:\n",
       "    Fully stop logging and close log file.\n",
       "    \n",
       "    In order to start logging again, a new %logstart call needs to be made,\n",
       "    possibly (though not necessarily) with a new filename, mode and other\n",
       "    options.\n",
       "%ls:\n",
       "    Alias for `!ls -F -G`\n",
       "%lsmagic:\n",
       "    List currently available magic functions.\n",
       "%lx:\n",
       "    Alias for `!ls -F -l -G %l | grep ^-..x`\n",
       "%macro:\n",
       "    Define a macro for future re-execution. It accepts ranges of history,\n",
       "    filenames or string objects.\n",
       "    \n",
       "    Usage::\n",
       "    \n",
       "      %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "    -r\n",
       "      Use 'raw' input.  By default, the 'processed' history is used,\n",
       "      so that magics are loaded in their transformed version to valid\n",
       "      Python.  If this option is given, the raw input as typed at the\n",
       "      command line is used instead.\n",
       "    \n",
       "    -q\n",
       "      Quiet macro definition.  By default, a tag line is printed\n",
       "      to indicate the macro has been created, and then the contents of\n",
       "      the macro are printed.  If this option is given, then no printout\n",
       "      is produced once the macro is created.\n",
       "    \n",
       "    This will define a global variable called `name` which is a string\n",
       "    made of joining the slices and lines you specify (n1,n2,... numbers\n",
       "    above) from your input history into a single string. This variable\n",
       "    acts like an automatic function which re-executes those lines as if\n",
       "    you had typed them. You just type 'name' at the prompt and the code\n",
       "    executes.\n",
       "    \n",
       "    The syntax for indicating input ranges is described in %history.\n",
       "    \n",
       "    Note: as a 'hidden' feature, you can also use traditional python slice\n",
       "    notation, where N:M means numbers N through M-1.\n",
       "    \n",
       "    For example, if your history contains (print using %hist -n )::\n",
       "    \n",
       "      44: x=1\n",
       "      45: y=3\n",
       "      46: z=x+y\n",
       "      47: print(x)\n",
       "      48: a=5\n",
       "      49: print('x',x,'y',y)\n",
       "    \n",
       "    you can create a macro with lines 44 through 47 (included) and line 49\n",
       "    called my_macro with::\n",
       "    \n",
       "      In [55]: %macro my_macro 44-47 49\n",
       "    \n",
       "    Now, typing `my_macro` (without quotes) will re-execute all this code\n",
       "    in one pass.\n",
       "    \n",
       "    You don't need to give the line-numbers in order, and any given line\n",
       "    number can appear multiple times. You can assemble macros with any\n",
       "    lines from your input history in any order.\n",
       "    \n",
       "    The macro is a simple object which holds its value in an attribute,\n",
       "    but IPython's display system checks for macros and executes them as\n",
       "    code instead of printing them when you type their name.\n",
       "    \n",
       "    You can view a macro's contents by explicitly printing it with::\n",
       "    \n",
       "      print(macro_name)\n",
       "%magic:\n",
       "    Print information about the magic function system.\n",
       "    \n",
       "    Supported formats: -latex, -brief, -rest\n",
       "%mamba:\n",
       "    Run the mamba package manager within the current kernel.\n",
       "    \n",
       "    Usage:\n",
       "      %mamba install [pkgs]\n",
       "%man:\n",
       "    Find the man page for the given command and display in pager.\n",
       "%matplotlib:\n",
       "    ::\n",
       "    \n",
       "      %matplotlib [-l] [gui]\n",
       "    \n",
       "    Set up matplotlib to work interactively.\n",
       "    \n",
       "    This function lets you activate matplotlib interactive support\n",
       "    at any point during an IPython session. It does not import anything\n",
       "    into the interactive namespace.\n",
       "    \n",
       "    If you are using the inline matplotlib backend in the IPython Notebook\n",
       "    you can set which figure formats are enabled using the following::\n",
       "    \n",
       "        In [1]: from matplotlib_inline.backend_inline import set_matplotlib_formats\n",
       "    \n",
       "        In [2]: set_matplotlib_formats('pdf', 'svg')\n",
       "    \n",
       "    The default for inline figures sets `bbox_inches` to 'tight'. This can\n",
       "    cause discrepancies between the displayed image and the identical\n",
       "    image created using `savefig`. This behavior can be disabled using the\n",
       "    `%config` magic::\n",
       "    \n",
       "        In [3]: %config InlineBackend.print_figure_kwargs = {'bbox_inches':None}\n",
       "    \n",
       "    In addition, see the docstrings of\n",
       "    `matplotlib_inline.backend_inline.set_matplotlib_formats` and\n",
       "    `matplotlib_inline.backend_inline.set_matplotlib_close` for more information on\n",
       "    changing additional behaviors of the inline backend.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    To enable the inline backend for usage with the IPython Notebook::\n",
       "    \n",
       "        In [1]: %matplotlib inline\n",
       "    \n",
       "    In this case, where the matplotlib default is TkAgg::\n",
       "    \n",
       "        In [2]: %matplotlib\n",
       "        Using matplotlib backend: TkAgg\n",
       "    \n",
       "    But you can explicitly request a different GUI backend::\n",
       "    \n",
       "        In [3]: %matplotlib qt\n",
       "    \n",
       "    You can list the available backends using the -l/--list option::\n",
       "    \n",
       "       In [4]: %matplotlib --list\n",
       "       Available matplotlib backends: ['osx', 'qt4', 'qt5', 'gtk3', 'gtk4', 'notebook', 'wx', 'qt', 'nbagg',\n",
       "       'gtk', 'tk', 'inline']\n",
       "    \n",
       "    positional arguments:\n",
       "      gui         Name of the matplotlib backend to use such as 'qt' or 'widget'. If given, the corresponding matplotlib backend is used,\n",
       "                  otherwise it will be matplotlib's default (which you can set in your matplotlib config file).\n",
       "    \n",
       "    options:\n",
       "      -l, --list  Show available matplotlib backends\n",
       "%micromamba:\n",
       "    Run the conda package manager within the current kernel.\n",
       "    \n",
       "    Usage:\n",
       "      %micromamba install [pkgs]\n",
       "%mkdir:\n",
       "    Alias for `!mkdir`\n",
       "%more:\n",
       "    Show a file through the pager.\n",
       "    \n",
       "    Files ending in .py are syntax-highlighted.\n",
       "%mv:\n",
       "    Alias for `!mv`\n",
       "%notebook:\n",
       "    ::\n",
       "    \n",
       "      %notebook filename\n",
       "    \n",
       "    Export and convert IPython notebooks.\n",
       "    \n",
       "    This function can export the current IPython history to a notebook file.\n",
       "    For example, to export the history to \"foo.ipynb\" do \"%notebook foo.ipynb\".\n",
       "    \n",
       "    positional arguments:\n",
       "      filename  Notebook name or filename\n",
       "%page:\n",
       "    Pretty print the object and display it through a pager.\n",
       "    \n",
       "    %page [options] OBJECT\n",
       "    \n",
       "    If no object is given, use _ (last output).\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "      -r: page str(object), don't pretty-print it.\n",
       "%pastebin:\n",
       "    Upload code to dpaste.com, returning the URL.\n",
       "    \n",
       "    Usage:\n",
       "      %pastebin [-d \"Custom description\"][-e 24] 1-7\n",
       "    \n",
       "    The argument can be an input history range, a filename, or the name of a\n",
       "    string or macro.\n",
       "    \n",
       "    If no arguments are given, uploads the history of this session up to\n",
       "    this point.\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "      -d: Pass a custom description. The default will say\n",
       "          \"Pasted from IPython\".\n",
       "      -e: Pass number of days for the link to be expired.\n",
       "          The default will be 7 days.\n",
       "%pdb:\n",
       "    Control the automatic calling of the pdb interactive debugger.\n",
       "    \n",
       "    Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without\n",
       "    argument it works as a toggle.\n",
       "    \n",
       "    When an exception is triggered, IPython can optionally call the\n",
       "    interactive pdb debugger after the traceback printout. %pdb toggles\n",
       "    this feature on and off.\n",
       "    \n",
       "    The initial state of this feature is set in your configuration\n",
       "    file (the option is ``InteractiveShell.pdb``).\n",
       "    \n",
       "    If you want to just activate the debugger AFTER an exception has fired,\n",
       "    without having to type '%pdb on' and rerunning your code, you can use\n",
       "    the %debug magic.\n",
       "%pdef:\n",
       "    Print the call signature for any callable object.\n",
       "    \n",
       "    If the object is a class, print the constructor information.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "      In [3]: %pdef urllib.urlopen\n",
       "      urllib.urlopen(url, data=None, proxies=None)\n",
       "%pdoc:\n",
       "    Print the docstring for an object.\n",
       "    \n",
       "    If the given object is a class, it will print both the class and the\n",
       "    constructor docstrings.\n",
       "%pfile:\n",
       "    Print (or run through pager) the file where an object is defined.\n",
       "    \n",
       "    The file opens at the line where the object definition begins. IPython\n",
       "    will honor the environment variable PAGER if set, and otherwise will\n",
       "    do its best to print the file in a convenient form.\n",
       "    \n",
       "    If the given argument is not an object currently defined, IPython will\n",
       "    try to interpret it as a filename (automatically adding a .py extension\n",
       "    if needed). You can thus use %pfile as a syntax highlighting code\n",
       "    viewer.\n",
       "%pinfo:\n",
       "    Provide detailed information about an object.\n",
       "    \n",
       "    '%pinfo object' is just a synonym for object? or ?object.\n",
       "%pinfo2:\n",
       "    Provide extra detailed information about an object.\n",
       "    \n",
       "    '%pinfo2 object' is just a synonym for object?? or ??object.\n",
       "%pip:\n",
       "    Run the pip package manager within the current kernel.\n",
       "    \n",
       "    Usage:\n",
       "      %pip install [pkgs]\n",
       "%popd:\n",
       "    Change to directory popped off the top of the stack.\n",
       "%pprint:\n",
       "    Toggle pretty printing on/off.\n",
       "%precision:\n",
       "    Set floating point precision for pretty printing.\n",
       "    \n",
       "    Can set either integer precision or a format string.\n",
       "    \n",
       "    If numpy has been imported and precision is an int,\n",
       "    numpy display precision will also be set, via ``numpy.set_printoptions``.\n",
       "    \n",
       "    If no argument is given, defaults will be restored.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "        In [1]: from math import pi\n",
       "    \n",
       "        In [2]: %precision 3\n",
       "        Out[2]: '%.3f'\n",
       "    \n",
       "        In [3]: pi\n",
       "        Out[3]: 3.142\n",
       "    \n",
       "        In [4]: %precision %i\n",
       "        Out[4]: '%i'\n",
       "    \n",
       "        In [5]: pi\n",
       "        Out[5]: 3\n",
       "    \n",
       "        In [6]: %precision %e\n",
       "        Out[6]: '%e'\n",
       "    \n",
       "        In [7]: pi**10\n",
       "        Out[7]: 9.364805e+04\n",
       "    \n",
       "        In [8]: %precision\n",
       "        Out[8]: '%r'\n",
       "    \n",
       "        In [9]: pi**10\n",
       "        Out[9]: 93648.047476082982\n",
       "%prun:\n",
       "    Run a statement through the python code profiler.\n",
       "    \n",
       "    **Usage, in line mode**::\n",
       "    \n",
       "      %prun [options] statement\n",
       "    \n",
       "    **Usage, in cell mode**::\n",
       "    \n",
       "      %%prun [options] [statement]\n",
       "      code...\n",
       "      code...\n",
       "    \n",
       "    In cell mode, the additional code lines are appended to the (possibly\n",
       "    empty) statement in the first line.  Cell mode allows you to easily\n",
       "    profile multiline blocks without having to put them in a separate\n",
       "    function.\n",
       "    \n",
       "    The given statement (which doesn't require quote marks) is run via the\n",
       "    python profiler in a manner similar to the profile.run() function.\n",
       "    Namespaces are internally managed to work correctly; profile.run\n",
       "    cannot be used in IPython because it makes certain assumptions about\n",
       "    namespaces which do not hold under IPython.\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "    -l <limit>\n",
       "      you can place restrictions on what or how much of the\n",
       "      profile gets printed. The limit value can be:\n",
       "    \n",
       "         * A string: only information for function names containing this string\n",
       "           is printed.\n",
       "    \n",
       "         * An integer: only these many lines are printed.\n",
       "    \n",
       "         * A float (between 0 and 1): this fraction of the report is printed\n",
       "           (for example, use a limit of 0.4 to see the topmost 40% only).\n",
       "    \n",
       "      You can combine several limits with repeated use of the option. For\n",
       "      example, ``-l __init__ -l 5`` will print only the topmost 5 lines of\n",
       "      information about class constructors.\n",
       "    \n",
       "    -r\n",
       "      return the pstats.Stats object generated by the profiling. This\n",
       "      object has all the information about the profile in it, and you can\n",
       "      later use it for further analysis or in other functions.\n",
       "    \n",
       "    -s <key>\n",
       "      sort profile by given key. You can provide more than one key\n",
       "      by using the option several times: '-s key1 -s key2 -s key3...'. The\n",
       "      default sorting key is 'time'.\n",
       "    \n",
       "      The following is copied verbatim from the profile documentation\n",
       "      referenced below:\n",
       "    \n",
       "      When more than one key is provided, additional keys are used as\n",
       "      secondary criteria when the there is equality in all keys selected\n",
       "      before them.\n",
       "    \n",
       "      Abbreviations can be used for any key names, as long as the\n",
       "      abbreviation is unambiguous.  The following are the keys currently\n",
       "      defined:\n",
       "    \n",
       "      ============  =====================\n",
       "      Valid Arg     Meaning\n",
       "      ============  =====================\n",
       "      \"calls\"       call count\n",
       "      \"cumulative\"  cumulative time\n",
       "      \"file\"        file name\n",
       "      \"module\"      file name\n",
       "      \"pcalls\"      primitive call count\n",
       "      \"line\"        line number\n",
       "      \"name\"        function name\n",
       "      \"nfl\"         name/file/line\n",
       "      \"stdname\"     standard name\n",
       "      \"time\"        internal time\n",
       "      ============  =====================\n",
       "    \n",
       "      Note that all sorts on statistics are in descending order (placing\n",
       "      most time consuming items first), where as name, file, and line number\n",
       "      searches are in ascending order (i.e., alphabetical). The subtle\n",
       "      distinction between \"nfl\" and \"stdname\" is that the standard name is a\n",
       "      sort of the name as printed, which means that the embedded line\n",
       "      numbers get compared in an odd way.  For example, lines 3, 20, and 40\n",
       "      would (if the file names were the same) appear in the string order\n",
       "      \"20\" \"3\" and \"40\".  In contrast, \"nfl\" does a numeric compare of the\n",
       "      line numbers.  In fact, sort_stats(\"nfl\") is the same as\n",
       "      sort_stats(\"name\", \"file\", \"line\").\n",
       "    \n",
       "    -T <filename>\n",
       "      save profile results as shown on screen to a text\n",
       "      file. The profile is still shown on screen.\n",
       "    \n",
       "    -D <filename>\n",
       "      save (via dump_stats) profile statistics to given\n",
       "      filename. This data is in a format understood by the pstats module, and\n",
       "      is generated by a call to the dump_stats() method of profile\n",
       "      objects. The profile is still shown on screen.\n",
       "    \n",
       "    -q\n",
       "      suppress output to the pager.  Best used with -T and/or -D above.\n",
       "    \n",
       "    If you want to run complete programs under the profiler's control, use\n",
       "    ``%run -p [prof_opts] filename.py [args to program]`` where prof_opts\n",
       "    contains profiler specific options as described here.\n",
       "    \n",
       "    You can read the complete documentation for the profile module with::\n",
       "    \n",
       "      In [1]: import profile; profile.help()\n",
       "    \n",
       "    .. versionchanged:: 7.3\n",
       "        User variables are no longer expanded,\n",
       "        the magic line is always left unmodified.\n",
       "%psearch:\n",
       "    Search for object in namespaces by wildcard.\n",
       "    \n",
       "    %psearch [options] PATTERN [OBJECT TYPE]\n",
       "    \n",
       "    Note: ? can be used as a synonym for %psearch, at the beginning or at\n",
       "    the end: both a*? and ?a* are equivalent to '%psearch a*'.  Still, the\n",
       "    rest of the command line must be unchanged (options come first), so\n",
       "    for example the following forms are equivalent\n",
       "    \n",
       "    %psearch -i a* function\n",
       "    -i a* function?\n",
       "    ?-i a* function\n",
       "    \n",
       "    Arguments:\n",
       "    \n",
       "      PATTERN\n",
       "    \n",
       "      where PATTERN is a string containing * as a wildcard similar to its\n",
       "      use in a shell.  The pattern is matched in all namespaces on the\n",
       "      search path. By default objects starting with a single _ are not\n",
       "      matched, many IPython generated objects have a single\n",
       "      underscore. The default is case insensitive matching. Matching is\n",
       "      also done on the attributes of objects and not only on the objects\n",
       "      in a module.\n",
       "    \n",
       "      [OBJECT TYPE]\n",
       "    \n",
       "      Is the name of a python type from the types module. The name is\n",
       "      given in lowercase without the ending type, ex. StringType is\n",
       "      written string. By adding a type here only objects matching the\n",
       "      given type are matched. Using all here makes the pattern match all\n",
       "      types (this is the default).\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "      -a: makes the pattern match even objects whose names start with a\n",
       "      single underscore.  These names are normally omitted from the\n",
       "      search.\n",
       "    \n",
       "      -i/-c: make the pattern case insensitive/sensitive.  If neither of\n",
       "      these options are given, the default is read from your configuration\n",
       "      file, with the option ``InteractiveShell.wildcards_case_sensitive``.\n",
       "      If this option is not specified in your configuration file, IPython's\n",
       "      internal default is to do a case sensitive search.\n",
       "    \n",
       "      -e/-s NAMESPACE: exclude/search a given namespace.  The pattern you\n",
       "      specify can be searched in any of the following namespaces:\n",
       "      'builtin', 'user', 'user_global','internal', 'alias', where\n",
       "      'builtin' and 'user' are the search defaults.  Note that you should\n",
       "      not use quotes when specifying namespaces.\n",
       "    \n",
       "      -l: List all available object types for object matching. This function\n",
       "      can be used without arguments.\n",
       "    \n",
       "      'Builtin' contains the python module builtin, 'user' contains all\n",
       "      user data, 'alias' only contain the shell aliases and no python\n",
       "      objects, 'internal' contains objects used by IPython.  The\n",
       "      'user_global' namespace is only used by embedded IPython instances,\n",
       "      and it contains module-level globals.  You can add namespaces to the\n",
       "      search with -s or exclude them with -e (these options can be given\n",
       "      more than once).\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "      %psearch a*            -> objects beginning with an a\n",
       "      %psearch -e builtin a* -> objects NOT in the builtin space starting in a\n",
       "      %psearch a* function   -> all functions beginning with an a\n",
       "      %psearch re.e*         -> objects beginning with an e in module re\n",
       "      %psearch r*.e*         -> objects that start with e in modules starting in r\n",
       "      %psearch r*.* string   -> all strings in modules beginning with r\n",
       "    \n",
       "    Case sensitive search::\n",
       "    \n",
       "      %psearch -c a*         list all object beginning with lower case a\n",
       "    \n",
       "    Show objects beginning with a single _::\n",
       "    \n",
       "      %psearch -a _*         list objects beginning with a single underscore\n",
       "    \n",
       "    List available objects::\n",
       "    \n",
       "      %psearch -l            list all available object types\n",
       "%psource:\n",
       "    Print (or run through pager) the source code for an object.\n",
       "%pushd:\n",
       "    Place the current dir on stack and change directory.\n",
       "    \n",
       "    Usage:\n",
       "      %pushd ['dirname']\n",
       "%pwd:\n",
       "    Return the current working directory path.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "      In [9]: pwd\n",
       "      Out[9]: '/home/tsuser/sprint/ipython'\n",
       "%pycat:\n",
       "    Show a syntax-highlighted file through a pager.\n",
       "    \n",
       "    This magic is similar to the cat utility, but it will assume the file\n",
       "    to be Python source and will show it with syntax highlighting.\n",
       "    \n",
       "    This magic command can either take a local filename, an url,\n",
       "    an history range (see %history) or a macro as argument.\n",
       "    \n",
       "    If no parameter is given, prints out history of current session up to\n",
       "    this point. ::\n",
       "    \n",
       "    %pycat myscript.py\n",
       "    %pycat 7-27\n",
       "    %pycat myMacro\n",
       "    %pycat http://www.example.com/myscript.py\n",
       "%pylab:\n",
       "    ::\n",
       "    \n",
       "      %pylab [--no-import-all] [gui]\n",
       "    \n",
       "    Load numpy and matplotlib to work interactively.\n",
       "    \n",
       "    This function lets you activate pylab (matplotlib, numpy and\n",
       "    interactive support) at any point during an IPython session.\n",
       "    \n",
       "    %pylab makes the following imports::\n",
       "    \n",
       "        import numpy\n",
       "        import matplotlib\n",
       "        from matplotlib import pylab, mlab, pyplot\n",
       "        np = numpy\n",
       "        plt = pyplot\n",
       "    \n",
       "        from IPython.display import display\n",
       "        from IPython.core.pylabtools import figsize, getfigs\n",
       "    \n",
       "        from pylab import *\n",
       "        from numpy import *\n",
       "    \n",
       "    If you pass `--no-import-all`, the last two `*` imports will be excluded.\n",
       "    \n",
       "    See the %matplotlib magic for more details about activating matplotlib\n",
       "    without affecting the interactive namespace.\n",
       "    \n",
       "    positional arguments:\n",
       "      gui              Name of the matplotlib backend to use such as 'qt' or 'widget'. If given, the corresponding matplotlib backend is used,\n",
       "                       otherwise it will be matplotlib's default (which you can set in your matplotlib config file).\n",
       "    \n",
       "    options:\n",
       "      --no-import-all  Prevent IPython from performing ``import *`` into the interactive namespace. You can govern the default behavior of this\n",
       "                       flag with the InteractiveShellApp.pylab_import_all configurable.\n",
       "%qtconsole:\n",
       "    Open a qtconsole connected to this kernel.\n",
       "    \n",
       "    Useful for connecting a qtconsole to running notebooks, for better\n",
       "    debugging.\n",
       "%quickref:\n",
       "    Show a quick reference sheet\n",
       "%recall:\n",
       "    Repeat a command, or get command to input line for editing.\n",
       "    \n",
       "    %recall and %rep are equivalent.\n",
       "    \n",
       "    - %recall (no arguments):\n",
       "    \n",
       "    Place a string version of last computation result (stored in the\n",
       "    special '_' variable) to the next input prompt. Allows you to create\n",
       "    elaborate command lines without using copy-paste::\n",
       "    \n",
       "         In[1]: l = [\"hei\", \"vaan\"]\n",
       "         In[2]: \"\".join(l)\n",
       "        Out[2]: heivaan\n",
       "         In[3]: %recall\n",
       "         In[4]: heivaan_ <== cursor blinking\n",
       "    \n",
       "    %recall 45\n",
       "    \n",
       "    Place history line 45 on the next input prompt. Use %hist to find\n",
       "    out the number.\n",
       "    \n",
       "    %recall 1-4\n",
       "    \n",
       "    Combine the specified lines into one cell, and place it on the next\n",
       "    input prompt. See %history for the slice syntax.\n",
       "    \n",
       "    %recall foo+bar\n",
       "    \n",
       "    If foo+bar can be evaluated in the user namespace, the result is\n",
       "    placed at the next input prompt. Otherwise, the history is searched\n",
       "    for lines which contain that substring, and the most recent one is\n",
       "    placed at the next input prompt.\n",
       "%rehashx:\n",
       "    Update the alias table with all executable files in $PATH.\n",
       "    \n",
       "    rehashx explicitly checks that every entry in $PATH is a file\n",
       "    with execute access (os.X_OK).\n",
       "    \n",
       "    Under Windows, it checks executability as a match against a\n",
       "    '|'-separated string of extensions, stored in the IPython config\n",
       "    variable win_exec_ext.  This defaults to 'exe|com|bat'.\n",
       "    \n",
       "    This function also resets the root module cache of module completer,\n",
       "    used on slow filesystems.\n",
       "%reload_ext:\n",
       "    Reload an IPython extension by its module name.\n",
       "%rep:\n",
       "    Alias for `%recall`.\n",
       "%rerun:\n",
       "    Re-run previous input\n",
       "    \n",
       "    By default, you can specify ranges of input history to be repeated\n",
       "    (as with %history). With no arguments, it will repeat the last line.\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "      -l <n> : Repeat the last n lines of input, not including the\n",
       "      current command.\n",
       "    \n",
       "      -g foo : Repeat the most recent line which contains foo\n",
       "%reset:\n",
       "    Resets the namespace by removing all names defined by the user, if\n",
       "    called without arguments, or by removing some types of objects, such\n",
       "    as everything currently in IPython's In[] and Out[] containers (see\n",
       "    the parameters for details).\n",
       "    \n",
       "    Parameters\n",
       "    ----------\n",
       "    -f\n",
       "        force reset without asking for confirmation.\n",
       "    -s\n",
       "        'Soft' reset: Only clears your namespace, leaving history intact.\n",
       "        References to objects may be kept. By default (without this option),\n",
       "        we do a 'hard' reset, giving you a new session and removing all\n",
       "        references to objects from the current session.\n",
       "    --aggressive\n",
       "        Try to aggressively remove modules from sys.modules ; this\n",
       "        may allow you to reimport Python modules that have been updated and\n",
       "        pick up changes, but can have unintended consequences.\n",
       "    \n",
       "    in\n",
       "        reset input history\n",
       "    out\n",
       "        reset output history\n",
       "    dhist\n",
       "        reset directory history\n",
       "    array\n",
       "        reset only variables that are NumPy arrays\n",
       "    \n",
       "    See Also\n",
       "    --------\n",
       "    reset_selective : invoked as ``%reset_selective``\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "      In [6]: a = 1\n",
       "    \n",
       "      In [7]: a\n",
       "      Out[7]: 1\n",
       "    \n",
       "      In [8]: 'a' in get_ipython().user_ns\n",
       "      Out[8]: True\n",
       "    \n",
       "      In [9]: %reset -f\n",
       "    \n",
       "      In [1]: 'a' in get_ipython().user_ns\n",
       "      Out[1]: False\n",
       "    \n",
       "      In [2]: %reset -f in\n",
       "      Flushing input history\n",
       "    \n",
       "      In [3]: %reset -f dhist in\n",
       "      Flushing directory history\n",
       "      Flushing input history\n",
       "    \n",
       "    Notes\n",
       "    -----\n",
       "    Calling this magic from clients that do not implement standard input,\n",
       "    such as the ipython notebook interface, will reset the namespace\n",
       "    without confirmation.\n",
       "%reset_selective:\n",
       "    Resets the namespace by removing names defined by the user.\n",
       "    \n",
       "    Input/Output history are left around in case you need them.\n",
       "    \n",
       "    %reset_selective [-f] regex\n",
       "    \n",
       "    No action is taken if regex is not included\n",
       "    \n",
       "    Options\n",
       "      -f : force reset without asking for confirmation.\n",
       "    \n",
       "    See Also\n",
       "    --------\n",
       "    reset : invoked as ``%reset``\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    We first fully reset the namespace so your output looks identical to\n",
       "    this example for pedagogical reasons; in practice you do not need a\n",
       "    full reset::\n",
       "    \n",
       "      In [1]: %reset -f\n",
       "    \n",
       "    Now, with a clean namespace we can make a few variables and use\n",
       "    ``%reset_selective`` to only delete names that match our regexp::\n",
       "    \n",
       "      In [2]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8\n",
       "    \n",
       "      In [3]: who_ls\n",
       "      Out[3]: ['a', 'b', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c']\n",
       "    \n",
       "      In [4]: %reset_selective -f b[2-3]m\n",
       "    \n",
       "      In [5]: who_ls\n",
       "      Out[5]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c']\n",
       "    \n",
       "      In [6]: %reset_selective -f d\n",
       "    \n",
       "      In [7]: who_ls\n",
       "      Out[7]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c']\n",
       "    \n",
       "      In [8]: %reset_selective -f c\n",
       "    \n",
       "      In [9]: who_ls\n",
       "      Out[9]: ['a', 'b', 'b1m', 'b2s', 'b4m']\n",
       "    \n",
       "      In [10]: %reset_selective -f b\n",
       "    \n",
       "      In [11]: who_ls\n",
       "      Out[11]: ['a']\n",
       "    \n",
       "    Notes\n",
       "    -----\n",
       "    Calling this magic from clients that do not implement standard input,\n",
       "    such as the ipython notebook interface, will reset the namespace\n",
       "    without confirmation.\n",
       "%rm:\n",
       "    Alias for `!rm`\n",
       "%rmdir:\n",
       "    Alias for `!rmdir`\n",
       "%run:\n",
       "    Run the named file inside IPython as a program.\n",
       "    \n",
       "    Usage::\n",
       "    \n",
       "      %run [-n -i -e -G]\n",
       "           [( -t [-N<N>] | -d [-b<N>] | -p [profile options] )]\n",
       "           ( -m mod | filename ) [args]\n",
       "    \n",
       "    The filename argument should be either a pure Python script (with\n",
       "    extension ``.py``), or a file with custom IPython syntax (such as\n",
       "    magics). If the latter, the file can be either a script with ``.ipy``\n",
       "    extension, or a Jupyter notebook with ``.ipynb`` extension. When running\n",
       "    a Jupyter notebook, the output from print statements and other\n",
       "    displayed objects will appear in the terminal (even matplotlib figures\n",
       "    will open, if a terminal-compliant backend is being used). Note that,\n",
       "    at the system command line, the ``jupyter run`` command offers similar\n",
       "    functionality for executing notebooks (albeit currently with some\n",
       "    differences in supported options).\n",
       "    \n",
       "    Parameters after the filename are passed as command-line arguments to\n",
       "    the program (put in sys.argv). Then, control returns to IPython's\n",
       "    prompt.\n",
       "    \n",
       "    This is similar to running at a system prompt ``python file args``,\n",
       "    but with the advantage of giving you IPython's tracebacks, and of\n",
       "    loading all variables into your interactive namespace for further use\n",
       "    (unless -p is used, see below).\n",
       "    \n",
       "    The file is executed in a namespace initially consisting only of\n",
       "    ``__name__=='__main__'`` and sys.argv constructed as indicated. It thus\n",
       "    sees its environment as if it were being run as a stand-alone program\n",
       "    (except for sharing global objects such as previously imported\n",
       "    modules). But after execution, the IPython interactive namespace gets\n",
       "    updated with all variables defined in the program (except for ``__name__``\n",
       "    and ``sys.argv``). This allows for very convenient loading of code for\n",
       "    interactive work, while giving each program a 'clean sheet' to run in.\n",
       "    \n",
       "    Arguments are expanded using shell-like glob match.  Patterns\n",
       "    '*', '?', '[seq]' and '[!seq]' can be used.  Additionally,\n",
       "    tilde '~' will be expanded into user's home directory.  Unlike\n",
       "    real shells, quotation does not suppress expansions.  Use\n",
       "    *two* back slashes (e.g. ``\\\\*``) to suppress expansions.\n",
       "    To completely disable these expansions, you can use -G flag.\n",
       "    \n",
       "    On Windows systems, the use of single quotes `'` when specifying\n",
       "    a file is not supported. Use double quotes `\"`.\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "    -n\n",
       "      __name__ is NOT set to '__main__', but to the running file's name\n",
       "      without extension (as python does under import).  This allows running\n",
       "      scripts and reloading the definitions in them without calling code\n",
       "      protected by an ``if __name__ == \"__main__\"`` clause.\n",
       "    \n",
       "    -i\n",
       "      run the file in IPython's namespace instead of an empty one. This\n",
       "      is useful if you are experimenting with code written in a text editor\n",
       "      which depends on variables defined interactively.\n",
       "    \n",
       "    -e\n",
       "      ignore sys.exit() calls or SystemExit exceptions in the script\n",
       "      being run.  This is particularly useful if IPython is being used to\n",
       "      run unittests, which always exit with a sys.exit() call.  In such\n",
       "      cases you are interested in the output of the test results, not in\n",
       "      seeing a traceback of the unittest module.\n",
       "    \n",
       "    -t\n",
       "      print timing information at the end of the run.  IPython will give\n",
       "      you an estimated CPU time consumption for your script, which under\n",
       "      Unix uses the resource module to avoid the wraparound problems of\n",
       "      time.clock().  Under Unix, an estimate of time spent on system tasks\n",
       "      is also given (for Windows platforms this is reported as 0.0).\n",
       "    \n",
       "      If -t is given, an additional ``-N<N>`` option can be given, where <N>\n",
       "      must be an integer indicating how many times you want the script to\n",
       "      run.  The final timing report will include total and per run results.\n",
       "    \n",
       "      For example (testing the script uniq_stable.py)::\n",
       "    \n",
       "          In [1]: run -t uniq_stable\n",
       "    \n",
       "          IPython CPU timings (estimated):\n",
       "            User  :    0.19597 s.\n",
       "            System:        0.0 s.\n",
       "    \n",
       "          In [2]: run -t -N5 uniq_stable\n",
       "    \n",
       "          IPython CPU timings (estimated):\n",
       "          Total runs performed: 5\n",
       "            Times :      Total       Per run\n",
       "            User  :   0.910862 s,  0.1821724 s.\n",
       "            System:        0.0 s,        0.0 s.\n",
       "    \n",
       "    -d\n",
       "      run your program under the control of pdb, the Python debugger.\n",
       "      This allows you to execute your program step by step, watch variables,\n",
       "      etc.  Internally, what IPython does is similar to calling::\n",
       "    \n",
       "          pdb.run('execfile(\"YOURFILENAME\")')\n",
       "    \n",
       "      with a breakpoint set on line 1 of your file.  You can change the line\n",
       "      number for this automatic breakpoint to be <N> by using the -bN option\n",
       "      (where N must be an integer). For example::\n",
       "    \n",
       "          %run -d -b40 myscript\n",
       "    \n",
       "      will set the first breakpoint at line 40 in myscript.py.  Note that\n",
       "      the first breakpoint must be set on a line which actually does\n",
       "      something (not a comment or docstring) for it to stop execution.\n",
       "    \n",
       "      Or you can specify a breakpoint in a different file::\n",
       "    \n",
       "          %run -d -b myotherfile.py:20 myscript\n",
       "    \n",
       "      When the pdb debugger starts, you will see a (Pdb) prompt.  You must\n",
       "      first enter 'c' (without quotes) to start execution up to the first\n",
       "      breakpoint.\n",
       "    \n",
       "      Entering 'help' gives information about the use of the debugger.  You\n",
       "      can easily see pdb's full documentation with \"import pdb;pdb.help()\"\n",
       "      at a prompt.\n",
       "    \n",
       "    -p\n",
       "      run program under the control of the Python profiler module (which\n",
       "      prints a detailed report of execution times, function calls, etc).\n",
       "    \n",
       "      You can pass other options after -p which affect the behavior of the\n",
       "      profiler itself. See the docs for %prun for details.\n",
       "    \n",
       "      In this mode, the program's variables do NOT propagate back to the\n",
       "      IPython interactive namespace (because they remain in the namespace\n",
       "      where the profiler executes them).\n",
       "    \n",
       "      Internally this triggers a call to %prun, see its documentation for\n",
       "      details on the options available specifically for profiling.\n",
       "    \n",
       "    There is one special usage for which the text above doesn't apply:\n",
       "    if the filename ends with .ipy[nb], the file is run as ipython script,\n",
       "    just as if the commands were written on IPython prompt.\n",
       "    \n",
       "    -m\n",
       "      specify module name to load instead of script path. Similar to\n",
       "      the -m option for the python interpreter. Use this option last if you\n",
       "      want to combine with other %run options. Unlike the python interpreter\n",
       "      only source modules are allowed no .pyc or .pyo files.\n",
       "      For example::\n",
       "    \n",
       "          %run -m example\n",
       "    \n",
       "      will run the example module.\n",
       "    \n",
       "    -G\n",
       "      disable shell-like glob expansion of arguments.\n",
       "%save:\n",
       "    Save a set of lines or a macro to a given filename.\n",
       "    \n",
       "    Usage:\n",
       "      %save [options] filename [history]\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "      -r: use 'raw' input.  By default, the 'processed' history is used,\n",
       "      so that magics are loaded in their transformed version to valid\n",
       "      Python.  If this option is given, the raw input as typed at the\n",
       "      command line is used instead.\n",
       "    \n",
       "      -f: force overwrite.  If file exists, %save will prompt for overwrite\n",
       "      unless -f is given.\n",
       "    \n",
       "      -a: append to the file instead of overwriting it.\n",
       "    \n",
       "    The history argument uses the same syntax as %history for input ranges,\n",
       "    then saves the lines to the filename you specify.\n",
       "    \n",
       "    If no ranges are specified, saves history of the current session up to\n",
       "    this point.\n",
       "    \n",
       "    It adds a '.py' extension to the file if you don't do so yourself, and\n",
       "    it asks for confirmation before overwriting existing files.\n",
       "    \n",
       "    If `-r` option is used, the default extension is `.ipy`.\n",
       "%sc:\n",
       "    Shell capture - run shell command and capture output (DEPRECATED use !).\n",
       "    \n",
       "    DEPRECATED. Suboptimal, retained for backwards compatibility.\n",
       "    \n",
       "    You should use the form 'var = !command' instead. Example:\n",
       "    \n",
       "     \"%sc -l myfiles = ls ~\" should now be written as\n",
       "    \n",
       "     \"myfiles = !ls ~\"\n",
       "    \n",
       "    myfiles.s, myfiles.l and myfiles.n still apply as documented\n",
       "    below.\n",
       "    \n",
       "    --\n",
       "    %sc [options] varname=command\n",
       "    \n",
       "    IPython will run the given command using commands.getoutput(), and\n",
       "    will then update the user's interactive namespace with a variable\n",
       "    called varname, containing the value of the call.  Your command can\n",
       "    contain shell wildcards, pipes, etc.\n",
       "    \n",
       "    The '=' sign in the syntax is mandatory, and the variable name you\n",
       "    supply must follow Python's standard conventions for valid names.\n",
       "    \n",
       "    (A special format without variable name exists for internal use)\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "      -l: list output.  Split the output on newlines into a list before\n",
       "      assigning it to the given variable.  By default the output is stored\n",
       "      as a single string.\n",
       "    \n",
       "      -v: verbose.  Print the contents of the variable.\n",
       "    \n",
       "    In most cases you should not need to split as a list, because the\n",
       "    returned value is a special type of string which can automatically\n",
       "    provide its contents either as a list (split on newlines) or as a\n",
       "    space-separated string.  These are convenient, respectively, either\n",
       "    for sequential processing or to be passed to a shell command.\n",
       "    \n",
       "    For example::\n",
       "    \n",
       "        # Capture into variable a\n",
       "        In [1]: sc a=ls *py\n",
       "    \n",
       "        # a is a string with embedded newlines\n",
       "        In [2]: a\n",
       "        Out[2]: 'setup.py\\nwin32_manual_post_install.py'\n",
       "    \n",
       "        # which can be seen as a list:\n",
       "        In [3]: a.l\n",
       "        Out[3]: ['setup.py', 'win32_manual_post_install.py']\n",
       "    \n",
       "        # or as a whitespace-separated string:\n",
       "        In [4]: a.s\n",
       "        Out[4]: 'setup.py win32_manual_post_install.py'\n",
       "    \n",
       "        # a.s is useful to pass as a single command line:\n",
       "        In [5]: !wc -l $a.s\n",
       "          146 setup.py\n",
       "          130 win32_manual_post_install.py\n",
       "          276 total\n",
       "    \n",
       "        # while the list form is useful to loop over:\n",
       "        In [6]: for f in a.l:\n",
       "           ...:      !wc -l $f\n",
       "           ...:\n",
       "        146 setup.py\n",
       "        130 win32_manual_post_install.py\n",
       "    \n",
       "    Similarly, the lists returned by the -l option are also special, in\n",
       "    the sense that you can equally invoke the .s attribute on them to\n",
       "    automatically get a whitespace-separated string from their contents::\n",
       "    \n",
       "        In [7]: sc -l b=ls *py\n",
       "    \n",
       "        In [8]: b\n",
       "        Out[8]: ['setup.py', 'win32_manual_post_install.py']\n",
       "    \n",
       "        In [9]: b.s\n",
       "        Out[9]: 'setup.py win32_manual_post_install.py'\n",
       "    \n",
       "    In summary, both the lists and strings used for output capture have\n",
       "    the following special attributes::\n",
       "    \n",
       "        .l (or .list) : value as list.\n",
       "        .n (or .nlstr): value as newline-separated string.\n",
       "        .s (or .spstr): value as space-separated string.\n",
       "%set_env:\n",
       "    Set environment variables.  Assumptions are that either \"val\" is a\n",
       "    name in the user namespace, or val is something that evaluates to a\n",
       "    string.\n",
       "    \n",
       "    Usage:\n",
       "      :``%set_env var val``: set value for var\n",
       "      :``%set_env var=val``: set value for var\n",
       "      :``%set_env var=$val``: set value for var, using python expansion if possible\n",
       "%store:\n",
       "    Lightweight persistence for python variables.\n",
       "    \n",
       "    Example::\n",
       "    \n",
       "      In [1]: l = ['hello',10,'world']\n",
       "      In [2]: %store l\n",
       "      Stored 'l' (list)\n",
       "      In [3]: exit\n",
       "    \n",
       "      (IPython session is closed and started again...)\n",
       "    \n",
       "      ville@badger:~$ ipython\n",
       "      In [1]: l\n",
       "      NameError: name 'l' is not defined\n",
       "      In [2]: %store -r\n",
       "      In [3]: l\n",
       "      Out[3]: ['hello', 10, 'world']\n",
       "    \n",
       "    Usage:\n",
       "    \n",
       "    * ``%store``          - Show list of all variables and their current\n",
       "                            values\n",
       "    * ``%store spam bar`` - Store the *current* value of the variables spam\n",
       "                            and bar to disk\n",
       "    * ``%store -d spam``  - Remove the variable and its value from storage\n",
       "    * ``%store -z``       - Remove all variables from storage\n",
       "    * ``%store -r``       - Refresh all variables, aliases and directory history\n",
       "                            from store (overwrite current vals)\n",
       "    * ``%store -r spam bar`` - Refresh specified variables and aliases from store\n",
       "                               (delete current val)\n",
       "    * ``%store foo >a.txt``  - Store value of foo to new file a.txt\n",
       "    * ``%store foo >>a.txt`` - Append value of foo to file a.txt\n",
       "    \n",
       "    It should be noted that if you change the value of a variable, you\n",
       "    need to %store it again if you want to persist the new value.\n",
       "    \n",
       "    Note also that the variables will need to be pickleable; most basic\n",
       "    python types can be safely %store'd.\n",
       "    \n",
       "    Also aliases can be %store'd across sessions.\n",
       "    To remove an alias from the storage, use the %unalias magic.\n",
       "%sx:\n",
       "    Shell execute - run shell command and capture output (!! is short-hand).\n",
       "    \n",
       "    %sx command\n",
       "    \n",
       "    IPython will run the given command using commands.getoutput(), and\n",
       "    return the result formatted as a list (split on '\\n').  Since the\n",
       "    output is _returned_, it will be stored in ipython's regular output\n",
       "    cache Out[N] and in the '_N' automatic variables.\n",
       "    \n",
       "    Notes:\n",
       "    \n",
       "    1) If an input line begins with '!!', then %sx is automatically\n",
       "    invoked.  That is, while::\n",
       "    \n",
       "      !ls\n",
       "    \n",
       "    causes ipython to simply issue system('ls'), typing::\n",
       "    \n",
       "      !!ls\n",
       "    \n",
       "    is a shorthand equivalent to::\n",
       "    \n",
       "      %sx ls\n",
       "    \n",
       "    2) %sx differs from %sc in that %sx automatically splits into a list,\n",
       "    like '%sc -l'.  The reason for this is to make it as easy as possible\n",
       "    to process line-oriented shell output via further python commands.\n",
       "    %sc is meant to provide much finer control, but requires more\n",
       "    typing.\n",
       "    \n",
       "    3) Just like %sc -l, this is a list with special attributes:\n",
       "    ::\n",
       "    \n",
       "      .l (or .list) : value as list.\n",
       "      .n (or .nlstr): value as newline-separated string.\n",
       "      .s (or .spstr): value as whitespace-separated string.\n",
       "    \n",
       "    This is very useful when trying to use such lists as arguments to\n",
       "    system commands.\n",
       "%system:\n",
       "    Shell execute - run shell command and capture output (!! is short-hand).\n",
       "    \n",
       "    %sx command\n",
       "    \n",
       "    IPython will run the given command using commands.getoutput(), and\n",
       "    return the result formatted as a list (split on '\\n').  Since the\n",
       "    output is _returned_, it will be stored in ipython's regular output\n",
       "    cache Out[N] and in the '_N' automatic variables.\n",
       "    \n",
       "    Notes:\n",
       "    \n",
       "    1) If an input line begins with '!!', then %sx is automatically\n",
       "    invoked.  That is, while::\n",
       "    \n",
       "      !ls\n",
       "    \n",
       "    causes ipython to simply issue system('ls'), typing::\n",
       "    \n",
       "      !!ls\n",
       "    \n",
       "    is a shorthand equivalent to::\n",
       "    \n",
       "      %sx ls\n",
       "    \n",
       "    2) %sx differs from %sc in that %sx automatically splits into a list,\n",
       "    like '%sc -l'.  The reason for this is to make it as easy as possible\n",
       "    to process line-oriented shell output via further python commands.\n",
       "    %sc is meant to provide much finer control, but requires more\n",
       "    typing.\n",
       "    \n",
       "    3) Just like %sc -l, this is a list with special attributes:\n",
       "    ::\n",
       "    \n",
       "      .l (or .list) : value as list.\n",
       "      .n (or .nlstr): value as newline-separated string.\n",
       "      .s (or .spstr): value as whitespace-separated string.\n",
       "    \n",
       "    This is very useful when trying to use such lists as arguments to\n",
       "    system commands.\n",
       "%tb:\n",
       "    Print the last traceback.\n",
       "    \n",
       "    Optionally, specify an exception reporting mode, tuning the\n",
       "    verbosity of the traceback. By default the currently-active exception\n",
       "    mode is used. See %xmode for changing exception reporting modes.\n",
       "    \n",
       "    Valid modes: Plain, Context, Verbose, and Minimal.\n",
       "%time:\n",
       "    ::\n",
       "    \n",
       "      %time [--no-raise-error]\n",
       "    \n",
       "    Time execution of a Python statement or expression.\n",
       "    \n",
       "    The CPU and wall clock times are printed, and the value of the\n",
       "    expression (if any) is returned.  Note that under Win32, system time\n",
       "    is always reported as 0, since it can not be measured.\n",
       "    \n",
       "    This function can be used both as a line and cell magic:\n",
       "    \n",
       "    - In line mode you can time a single-line statement (though multiple\n",
       "      ones can be chained with using semicolons).\n",
       "    \n",
       "    - In cell mode, you can time the cell body (a directly\n",
       "      following statement raises an error).\n",
       "    \n",
       "    This function provides very basic timing functionality. Use the timeit\n",
       "    magic for more control over the measurement.\n",
       "    \n",
       "    .. versionchanged:: 7.3\n",
       "        User variables are no longer expanded,\n",
       "        the magic line is always left unmodified.\n",
       "    \n",
       "    .. versionchanged:: 8.3\n",
       "        The time magic now correctly propagates system-exiting exceptions\n",
       "        (such as ``KeyboardInterrupt`` invoked when interrupting execution)\n",
       "        rather than just printing out the exception traceback.\n",
       "        The non-system-exception will still be caught as before.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "      In [1]: %time 2**128\n",
       "      CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "      Wall time: 0.00\n",
       "      Out[1]: 340282366920938463463374607431768211456L\n",
       "    \n",
       "      In [2]: n = 1000000\n",
       "    \n",
       "      In [3]: %time sum(range(n))\n",
       "      CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s\n",
       "      Wall time: 1.37\n",
       "      Out[3]: 499999500000L\n",
       "    \n",
       "      In [4]: %time print('hello world')\n",
       "      hello world\n",
       "      CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "      Wall time: 0.00\n",
       "    \n",
       "    .. note::\n",
       "        The time needed by Python to compile the given expression will be\n",
       "        reported if it is more than 0.1s.\n",
       "    \n",
       "        In the example below, the actual exponentiation is done by Python\n",
       "        at compilation time, so while the expression can take a noticeable\n",
       "        amount of time to compute, that time is purely due to the\n",
       "        compilation::\n",
       "    \n",
       "            In [5]: %time 3**9999;\n",
       "            CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "            Wall time: 0.00 s\n",
       "    \n",
       "            In [6]: %time 3**999999;\n",
       "            CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "            Wall time: 0.00 s\n",
       "            Compiler : 0.78 s\n",
       "    \n",
       "    options:\n",
       "      --no-raise-error  If given, don't re-raise exceptions\n",
       "%timeit:\n",
       "    Time execution of a Python statement or expression\n",
       "    \n",
       "    **Usage, in line mode**::\n",
       "    \n",
       "      %timeit [-n<N> -r<R> [-t|-c] -q -p<P> [-o|-v <V>]] statement\n",
       "    \n",
       "    **or in cell mode**::\n",
       "    \n",
       "      %%timeit [-n<N> -r<R> [-t|-c] -q -p<P> [-o|-v <V>]] setup_code\n",
       "      code\n",
       "      code...\n",
       "    \n",
       "    Time execution of a Python statement or expression using the timeit\n",
       "    module.  This function can be used both as a line and cell magic:\n",
       "    \n",
       "    - In line mode you can time a single-line statement (though multiple\n",
       "      ones can be chained with using semicolons).\n",
       "    \n",
       "    - In cell mode, the statement in the first line is used as setup code\n",
       "      (executed but not timed) and the body of the cell is timed.  The cell\n",
       "      body has access to any variables created in the setup code.\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "    -n<N>\n",
       "      Execute the given statement N times in a loop. If N is not\n",
       "      provided, N is determined so as to get sufficient accuracy.\n",
       "    \n",
       "    -r<R>\n",
       "      Number of repeats R, each consisting of N loops, and take the\n",
       "      average result.\n",
       "      Default: 7\n",
       "    \n",
       "    -t\n",
       "      Use ``time.time`` to measure the time, which is the default on Unix.\n",
       "      This function measures wall time.\n",
       "    \n",
       "    -c\n",
       "      Use ``time.clock`` to measure the time, which is the default on\n",
       "      Windows and measures wall time. On Unix, ``resource.getrusage`` is used\n",
       "      instead and returns the CPU user time.\n",
       "    \n",
       "    -p<P>\n",
       "      Use a precision of P digits to display the timing result.\n",
       "      Default: 3\n",
       "    \n",
       "    -q\n",
       "      Quiet, do not print result.\n",
       "    \n",
       "    -o\n",
       "      Return a ``TimeitResult`` that can be stored in a variable to inspect\n",
       "      the result in more details.\n",
       "    \n",
       "    -v <V>\n",
       "      Like ``-o``, but save the ``TimeitResult`` directly to variable <V>.\n",
       "    \n",
       "    .. versionchanged:: 7.3\n",
       "        User variables are no longer expanded,\n",
       "        the magic line is always left unmodified.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "      In [1]: %timeit pass\n",
       "      8.26 ns ± 0.12 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)\n",
       "    \n",
       "      In [2]: u = None\n",
       "    \n",
       "      In [3]: %timeit u is None\n",
       "      29.9 ns ± 0.643 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n",
       "    \n",
       "      In [4]: %timeit -r 4 u == None\n",
       "    \n",
       "      In [5]: import time\n",
       "    \n",
       "      In [6]: %timeit -n1 time.sleep(2)\n",
       "    \n",
       "    The times reported by ``%timeit`` will be slightly higher than those\n",
       "    reported by the timeit.py script when variables are accessed. This is\n",
       "    due to the fact that ``%timeit`` executes the statement in the namespace\n",
       "    of the shell, compared with timeit.py, which uses a single setup\n",
       "    statement to import function or create variables. Generally, the bias\n",
       "    does not matter as long as results from timeit.py are not mixed with\n",
       "    those from ``%timeit``.\n",
       "%unalias:\n",
       "    Remove an alias\n",
       "%unload_ext:\n",
       "    Unload an IPython extension by its module name.\n",
       "    \n",
       "    Not all extensions can be unloaded, only those which define an\n",
       "    ``unload_ipython_extension`` function.\n",
       "%uv:\n",
       "    Run the uv package manager within the current kernel.\n",
       "    \n",
       "    Usage:\n",
       "      %uv pip install [pkgs]\n",
       "%who:\n",
       "    Print all interactive variables, with some minimal formatting.\n",
       "    \n",
       "    If any arguments are given, only variables whose type matches one of\n",
       "    these are printed.  For example::\n",
       "    \n",
       "      %who function str\n",
       "    \n",
       "    will only list functions and strings, excluding all other types of\n",
       "    variables.  To find the proper type names, simply use type(var) at a\n",
       "    command line to see how python prints type names.  For example:\n",
       "    \n",
       "    ::\n",
       "    \n",
       "      In [1]: type('hello')\n",
       "      Out[1]: <type 'str'>\n",
       "    \n",
       "    indicates that the type name for strings is 'str'.\n",
       "    \n",
       "    ``%who`` always excludes executed names loaded through your configuration\n",
       "    file and things which are internal to IPython.\n",
       "    \n",
       "    This is deliberate, as typically you may load many modules and the\n",
       "    purpose of %who is to show you only what you've manually defined.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    \n",
       "    Define two variables and list them with who::\n",
       "    \n",
       "      In [1]: alpha = 123\n",
       "    \n",
       "      In [2]: beta = 'test'\n",
       "    \n",
       "      In [3]: %who\n",
       "      alpha   beta\n",
       "    \n",
       "      In [4]: %who int\n",
       "      alpha\n",
       "    \n",
       "      In [5]: %who str\n",
       "      beta\n",
       "%who_ls:\n",
       "    Return a sorted list of all interactive variables.\n",
       "    \n",
       "    If arguments are given, only variables of types matching these\n",
       "    arguments are returned.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    Define two variables and list them with who_ls::\n",
       "    \n",
       "      In [1]: alpha = 123\n",
       "    \n",
       "      In [2]: beta = 'test'\n",
       "    \n",
       "      In [3]: %who_ls\n",
       "      Out[3]: ['alpha', 'beta']\n",
       "    \n",
       "      In [4]: %who_ls int\n",
       "      Out[4]: ['alpha']\n",
       "    \n",
       "      In [5]: %who_ls str\n",
       "      Out[5]: ['beta']\n",
       "%whos:\n",
       "    Like %who, but gives some extra information about each variable.\n",
       "    \n",
       "    The same type filtering of %who can be applied here.\n",
       "    \n",
       "    For all variables, the type is printed. Additionally it prints:\n",
       "    \n",
       "      - For {},[],(): their length.\n",
       "    \n",
       "      - For numpy arrays, a summary with shape, number of\n",
       "        elements, typecode and size in memory.\n",
       "    \n",
       "      - For DataFrame and Series types: their shape.\n",
       "    \n",
       "      - Everything else: a string representation, snipping their middle if\n",
       "        too long.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    Define two variables and list them with whos::\n",
       "    \n",
       "      In [1]: alpha = 123\n",
       "    \n",
       "      In [2]: beta = 'test'\n",
       "    \n",
       "      In [3]: df = pd.DataFrame({\"a\": range(10), \"b\": range(10,20)})\n",
       "    \n",
       "      In [4]: s = df[\"a\"]\n",
       "    \n",
       "      In [5]: %whos\n",
       "      Variable   Type        Data/Info\n",
       "      --------------------------------\n",
       "      alpha      int         123\n",
       "      beta       str         test\n",
       "      df         DataFrame   Shape: (10, 2)\n",
       "      s          Series      Shape: (10, )\n",
       "%xdel:\n",
       "    Delete a variable, trying to clear it from anywhere that\n",
       "    IPython's machinery has references to it. By default, this uses\n",
       "    the identity of the named object in the user namespace to remove\n",
       "    references held under other names. The object is also removed\n",
       "    from the output history.\n",
       "    \n",
       "    Options\n",
       "      -n : Delete the specified name from all namespaces, without\n",
       "      checking their identity.\n",
       "%xmode:\n",
       "    Switch modes for the exception handlers.\n",
       "    \n",
       "    Valid modes: Plain, Context, Verbose, and Minimal.\n",
       "    \n",
       "    If called without arguments, acts as a toggle.\n",
       "    \n",
       "    When in verbose mode the value `--show` (and `--hide`)\n",
       "    will respectively show (or hide) frames with ``__tracebackhide__ =\n",
       "    True`` value set.\n",
       "%%!:\n",
       "    Shell execute - run shell command and capture output (!! is short-hand).\n",
       "    \n",
       "    %sx command\n",
       "    \n",
       "    IPython will run the given command using commands.getoutput(), and\n",
       "    return the result formatted as a list (split on '\\n').  Since the\n",
       "    output is _returned_, it will be stored in ipython's regular output\n",
       "    cache Out[N] and in the '_N' automatic variables.\n",
       "    \n",
       "    Notes:\n",
       "    \n",
       "    1) If an input line begins with '!!', then %sx is automatically\n",
       "    invoked.  That is, while::\n",
       "    \n",
       "      !ls\n",
       "    \n",
       "    causes ipython to simply issue system('ls'), typing::\n",
       "    \n",
       "      !!ls\n",
       "    \n",
       "    is a shorthand equivalent to::\n",
       "    \n",
       "      %sx ls\n",
       "    \n",
       "    2) %sx differs from %sc in that %sx automatically splits into a list,\n",
       "    like '%sc -l'.  The reason for this is to make it as easy as possible\n",
       "    to process line-oriented shell output via further python commands.\n",
       "    %sc is meant to provide much finer control, but requires more\n",
       "    typing.\n",
       "    \n",
       "    3) Just like %sc -l, this is a list with special attributes:\n",
       "    ::\n",
       "    \n",
       "      .l (or .list) : value as list.\n",
       "      .n (or .nlstr): value as newline-separated string.\n",
       "      .s (or .spstr): value as whitespace-separated string.\n",
       "    \n",
       "    This is very useful when trying to use such lists as arguments to\n",
       "    system commands.\n",
       "%%HTML:\n",
       "    Alias for `%%html`.\n",
       "%%SVG:\n",
       "    Alias for `%%svg`.\n",
       "%%bash:\n",
       "    %%bash script magic\n",
       "    \n",
       "    Run cells with bash in a subprocess.\n",
       "    \n",
       "    This is a shortcut for `%%script bash`\n",
       "%%capture:\n",
       "    ::\n",
       "    \n",
       "      %capture [--no-stderr] [--no-stdout] [--no-display] [output]\n",
       "    \n",
       "    run the cell, capturing stdout, stderr, and IPython's rich display() calls.\n",
       "    \n",
       "    positional arguments:\n",
       "      output        The name of the variable in which to store output. This is a ``utils.io.CapturedIO`` object with stdout/err attributes for\n",
       "                    the text of the captured output. CapturedOutput also has a ``show()`` method for displaying the output, and ``__call__`` as\n",
       "                    well, so you can use that to quickly display the output. If unspecified, captured output is discarded.\n",
       "    \n",
       "    options:\n",
       "      --no-stderr   Don't capture stderr.\n",
       "      --no-stdout   Don't capture stdout.\n",
       "      --no-display  Don't capture IPython's rich display.\n",
       "%%code_wrap:\n",
       "    ::\n",
       "    \n",
       "      %code_wrap [--remove] [--list] [--list-all] [name]\n",
       "    \n",
       "    Simple magic to quickly define a code transformer for all IPython's future input.\n",
       "    \n",
       "    ``__code__`` and ``__ret__`` are special variable that represent the code to run\n",
       "    and the value of the last expression of ``__code__`` respectively.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    \n",
       "    .. ipython::\n",
       "    \n",
       "        In [1]: %%code_wrap before_after\n",
       "           ...: print('before')\n",
       "           ...: __code__\n",
       "           ...: print('after')\n",
       "           ...: __ret__\n",
       "    \n",
       "        In [2]: 1\n",
       "        before\n",
       "        after\n",
       "        Out[2]: 1\n",
       "    \n",
       "        In [3]: %code_wrap --list\n",
       "        before_after\n",
       "    \n",
       "        In [4]: %code_wrap --list-all\n",
       "        before_after :\n",
       "            print('before')\n",
       "            __code__\n",
       "            print('after')\n",
       "            __ret__\n",
       "    \n",
       "        In [5]: %code_wrap --remove before_after\n",
       "    \n",
       "    positional arguments:\n",
       "      name\n",
       "    \n",
       "    options:\n",
       "      --remove    remove the current transformer\n",
       "      --list      list existing transformers name\n",
       "      --list-all  list existing transformers name and code template\n",
       "%%debug:\n",
       "    ::\n",
       "    \n",
       "      %debug [--breakpoint FILE:LINE] [statement ...]\n",
       "    \n",
       "    Activate the interactive debugger.\n",
       "    \n",
       "    This magic command support two ways of activating debugger.\n",
       "    One is to activate debugger before executing code.  This way, you\n",
       "    can set a break point, to step through the code from the point.\n",
       "    You can use this mode by giving statements to execute and optionally\n",
       "    a breakpoint.\n",
       "    \n",
       "    The other one is to activate debugger in post-mortem mode.  You can\n",
       "    activate this mode simply running %debug without any argument.\n",
       "    If an exception has just occurred, this lets you inspect its stack\n",
       "    frames interactively.  Note that this will always work only on the last\n",
       "    traceback that occurred, so you must call this quickly after an\n",
       "    exception that you wish to inspect has fired, because if another one\n",
       "    occurs, it clobbers the previous one.\n",
       "    \n",
       "    If you want IPython to automatically do this on every exception, see\n",
       "    the %pdb magic for more details.\n",
       "    \n",
       "    .. versionchanged:: 7.3\n",
       "        When running code, user variables are no longer expanded,\n",
       "        the magic line is always left unmodified.\n",
       "    \n",
       "    positional arguments:\n",
       "      statement             Code to run in debugger. You can omit this in cell magic mode.\n",
       "    \n",
       "    options:\n",
       "      --breakpoint <FILE:LINE>, -b <FILE:LINE>\n",
       "                            Set break point at LINE in FILE.\n",
       "%%file:\n",
       "    Alias for `%%writefile`.\n",
       "%%html:\n",
       "    ::\n",
       "    \n",
       "      %html [--isolated]\n",
       "    \n",
       "    Render the cell as a block of HTML\n",
       "    \n",
       "    options:\n",
       "      --isolated  Annotate the cell as 'isolated'. Isolated cells are rendered inside their own <iframe> tag\n",
       "%%javascript:\n",
       "    Run the cell block of Javascript code\n",
       "    \n",
       "    Starting with IPython 8.0 %%javascript is pending deprecation to be replaced\n",
       "    by a more flexible system\n",
       "    \n",
       "    Please See https://github.com/ipython/ipython/issues/13376\n",
       "%%js:\n",
       "    Run the cell block of Javascript code\n",
       "    \n",
       "    Alias of `%%javascript`\n",
       "    \n",
       "    Starting with IPython 8.0 %%javascript is pending deprecation to be replaced\n",
       "    by a more flexible system\n",
       "    \n",
       "    Please See https://github.com/ipython/ipython/issues/13376\n",
       "%%latex:\n",
       "    Render the cell as a block of LaTeX\n",
       "    \n",
       "    The subset of LaTeX which is supported depends on the implementation in\n",
       "    the client.  In the Jupyter Notebook, this magic only renders the subset\n",
       "    of LaTeX defined by MathJax\n",
       "    [here](https://docs.mathjax.org/en/v2.5-latest/tex.html).\n",
       "%%markdown:\n",
       "    Render the cell as Markdown text block\n",
       "%%perl:\n",
       "    %%perl script magic\n",
       "    \n",
       "    Run cells with perl in a subprocess.\n",
       "    \n",
       "    This is a shortcut for `%%script perl`\n",
       "%%prun:\n",
       "    Run a statement through the python code profiler.\n",
       "    \n",
       "    **Usage, in line mode**::\n",
       "    \n",
       "      %prun [options] statement\n",
       "    \n",
       "    **Usage, in cell mode**::\n",
       "    \n",
       "      %%prun [options] [statement]\n",
       "      code...\n",
       "      code...\n",
       "    \n",
       "    In cell mode, the additional code lines are appended to the (possibly\n",
       "    empty) statement in the first line.  Cell mode allows you to easily\n",
       "    profile multiline blocks without having to put them in a separate\n",
       "    function.\n",
       "    \n",
       "    The given statement (which doesn't require quote marks) is run via the\n",
       "    python profiler in a manner similar to the profile.run() function.\n",
       "    Namespaces are internally managed to work correctly; profile.run\n",
       "    cannot be used in IPython because it makes certain assumptions about\n",
       "    namespaces which do not hold under IPython.\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "    -l <limit>\n",
       "      you can place restrictions on what or how much of the\n",
       "      profile gets printed. The limit value can be:\n",
       "    \n",
       "         * A string: only information for function names containing this string\n",
       "           is printed.\n",
       "    \n",
       "         * An integer: only these many lines are printed.\n",
       "    \n",
       "         * A float (between 0 and 1): this fraction of the report is printed\n",
       "           (for example, use a limit of 0.4 to see the topmost 40% only).\n",
       "    \n",
       "      You can combine several limits with repeated use of the option. For\n",
       "      example, ``-l __init__ -l 5`` will print only the topmost 5 lines of\n",
       "      information about class constructors.\n",
       "    \n",
       "    -r\n",
       "      return the pstats.Stats object generated by the profiling. This\n",
       "      object has all the information about the profile in it, and you can\n",
       "      later use it for further analysis or in other functions.\n",
       "    \n",
       "    -s <key>\n",
       "      sort profile by given key. You can provide more than one key\n",
       "      by using the option several times: '-s key1 -s key2 -s key3...'. The\n",
       "      default sorting key is 'time'.\n",
       "    \n",
       "      The following is copied verbatim from the profile documentation\n",
       "      referenced below:\n",
       "    \n",
       "      When more than one key is provided, additional keys are used as\n",
       "      secondary criteria when the there is equality in all keys selected\n",
       "      before them.\n",
       "    \n",
       "      Abbreviations can be used for any key names, as long as the\n",
       "      abbreviation is unambiguous.  The following are the keys currently\n",
       "      defined:\n",
       "    \n",
       "      ============  =====================\n",
       "      Valid Arg     Meaning\n",
       "      ============  =====================\n",
       "      \"calls\"       call count\n",
       "      \"cumulative\"  cumulative time\n",
       "      \"file\"        file name\n",
       "      \"module\"      file name\n",
       "      \"pcalls\"      primitive call count\n",
       "      \"line\"        line number\n",
       "      \"name\"        function name\n",
       "      \"nfl\"         name/file/line\n",
       "      \"stdname\"     standard name\n",
       "      \"time\"        internal time\n",
       "      ============  =====================\n",
       "    \n",
       "      Note that all sorts on statistics are in descending order (placing\n",
       "      most time consuming items first), where as name, file, and line number\n",
       "      searches are in ascending order (i.e., alphabetical). The subtle\n",
       "      distinction between \"nfl\" and \"stdname\" is that the standard name is a\n",
       "      sort of the name as printed, which means that the embedded line\n",
       "      numbers get compared in an odd way.  For example, lines 3, 20, and 40\n",
       "      would (if the file names were the same) appear in the string order\n",
       "      \"20\" \"3\" and \"40\".  In contrast, \"nfl\" does a numeric compare of the\n",
       "      line numbers.  In fact, sort_stats(\"nfl\") is the same as\n",
       "      sort_stats(\"name\", \"file\", \"line\").\n",
       "    \n",
       "    -T <filename>\n",
       "      save profile results as shown on screen to a text\n",
       "      file. The profile is still shown on screen.\n",
       "    \n",
       "    -D <filename>\n",
       "      save (via dump_stats) profile statistics to given\n",
       "      filename. This data is in a format understood by the pstats module, and\n",
       "      is generated by a call to the dump_stats() method of profile\n",
       "      objects. The profile is still shown on screen.\n",
       "    \n",
       "    -q\n",
       "      suppress output to the pager.  Best used with -T and/or -D above.\n",
       "    \n",
       "    If you want to run complete programs under the profiler's control, use\n",
       "    ``%run -p [prof_opts] filename.py [args to program]`` where prof_opts\n",
       "    contains profiler specific options as described here.\n",
       "    \n",
       "    You can read the complete documentation for the profile module with::\n",
       "    \n",
       "      In [1]: import profile; profile.help()\n",
       "    \n",
       "    .. versionchanged:: 7.3\n",
       "        User variables are no longer expanded,\n",
       "        the magic line is always left unmodified.\n",
       "%%pypy:\n",
       "    %%pypy script magic\n",
       "    \n",
       "    Run cells with pypy in a subprocess.\n",
       "    \n",
       "    This is a shortcut for `%%script pypy`\n",
       "%%python:\n",
       "    %%python script magic\n",
       "    \n",
       "    Run cells with python in a subprocess.\n",
       "    \n",
       "    This is a shortcut for `%%script python`\n",
       "%%python2:\n",
       "    %%python2 script magic\n",
       "    \n",
       "    Run cells with python2 in a subprocess.\n",
       "    \n",
       "    This is a shortcut for `%%script python2`\n",
       "%%python3:\n",
       "    %%python3 script magic\n",
       "    \n",
       "    Run cells with python3 in a subprocess.\n",
       "    \n",
       "    This is a shortcut for `%%script python3`\n",
       "%%ruby:\n",
       "    %%ruby script magic\n",
       "    \n",
       "    Run cells with ruby in a subprocess.\n",
       "    \n",
       "    This is a shortcut for `%%script ruby`\n",
       "%%script:\n",
       "    ::\n",
       "    \n",
       "      %shebang [--no-raise-error] [--proc PROC] [--bg] [--err ERR] [--out OUT]\n",
       "    \n",
       "    Run a cell via a shell command\n",
       "    \n",
       "    The `%%script` line is like the #! line of script,\n",
       "    specifying a program (bash, perl, ruby, etc.) with which to run.\n",
       "    \n",
       "    The rest of the cell is run by that program.\n",
       "    \n",
       "    .. versionchanged:: 9.0\n",
       "      Interrupting the script executed without `--bg` will end in\n",
       "      raising an exception (unless `--no-raise-error` is passed).\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "        In [1]: %%script bash\n",
       "           ...: for i in 1 2 3; do\n",
       "           ...:   echo $i\n",
       "           ...: done\n",
       "        1\n",
       "        2\n",
       "        3\n",
       "    \n",
       "    options:\n",
       "      --no-raise-error  Whether you should raise an error message in addition to a stream on stderr if you get a nonzero exit code.\n",
       "      --proc PROC       The variable in which to store Popen instance. This is used only when --bg option is given.\n",
       "      --bg              Whether to run the script in the background. If given, the only way to see the output of the command is with --out/err.\n",
       "      --err ERR         The variable in which to store stderr from the script. If the script is backgrounded, this will be the stderr *pipe*,\n",
       "                        instead of the stderr text itself and will not be autoclosed.\n",
       "      --out OUT         The variable in which to store stdout from the script. If the script is backgrounded, this will be the stdout *pipe*,\n",
       "                        instead of the stderr text itself and will not be auto closed.\n",
       "%%sh:\n",
       "    %%sh script magic\n",
       "    \n",
       "    Run cells with sh in a subprocess.\n",
       "    \n",
       "    This is a shortcut for `%%script sh`\n",
       "%%svg:\n",
       "    Render the cell as an SVG literal\n",
       "%%sx:\n",
       "    Shell execute - run shell command and capture output (!! is short-hand).\n",
       "    \n",
       "    %sx command\n",
       "    \n",
       "    IPython will run the given command using commands.getoutput(), and\n",
       "    return the result formatted as a list (split on '\\n').  Since the\n",
       "    output is _returned_, it will be stored in ipython's regular output\n",
       "    cache Out[N] and in the '_N' automatic variables.\n",
       "    \n",
       "    Notes:\n",
       "    \n",
       "    1) If an input line begins with '!!', then %sx is automatically\n",
       "    invoked.  That is, while::\n",
       "    \n",
       "      !ls\n",
       "    \n",
       "    causes ipython to simply issue system('ls'), typing::\n",
       "    \n",
       "      !!ls\n",
       "    \n",
       "    is a shorthand equivalent to::\n",
       "    \n",
       "      %sx ls\n",
       "    \n",
       "    2) %sx differs from %sc in that %sx automatically splits into a list,\n",
       "    like '%sc -l'.  The reason for this is to make it as easy as possible\n",
       "    to process line-oriented shell output via further python commands.\n",
       "    %sc is meant to provide much finer control, but requires more\n",
       "    typing.\n",
       "    \n",
       "    3) Just like %sc -l, this is a list with special attributes:\n",
       "    ::\n",
       "    \n",
       "      .l (or .list) : value as list.\n",
       "      .n (or .nlstr): value as newline-separated string.\n",
       "      .s (or .spstr): value as whitespace-separated string.\n",
       "    \n",
       "    This is very useful when trying to use such lists as arguments to\n",
       "    system commands.\n",
       "%%system:\n",
       "    Shell execute - run shell command and capture output (!! is short-hand).\n",
       "    \n",
       "    %sx command\n",
       "    \n",
       "    IPython will run the given command using commands.getoutput(), and\n",
       "    return the result formatted as a list (split on '\\n').  Since the\n",
       "    output is _returned_, it will be stored in ipython's regular output\n",
       "    cache Out[N] and in the '_N' automatic variables.\n",
       "    \n",
       "    Notes:\n",
       "    \n",
       "    1) If an input line begins with '!!', then %sx is automatically\n",
       "    invoked.  That is, while::\n",
       "    \n",
       "      !ls\n",
       "    \n",
       "    causes ipython to simply issue system('ls'), typing::\n",
       "    \n",
       "      !!ls\n",
       "    \n",
       "    is a shorthand equivalent to::\n",
       "    \n",
       "      %sx ls\n",
       "    \n",
       "    2) %sx differs from %sc in that %sx automatically splits into a list,\n",
       "    like '%sc -l'.  The reason for this is to make it as easy as possible\n",
       "    to process line-oriented shell output via further python commands.\n",
       "    %sc is meant to provide much finer control, but requires more\n",
       "    typing.\n",
       "    \n",
       "    3) Just like %sc -l, this is a list with special attributes:\n",
       "    ::\n",
       "    \n",
       "      .l (or .list) : value as list.\n",
       "      .n (or .nlstr): value as newline-separated string.\n",
       "      .s (or .spstr): value as whitespace-separated string.\n",
       "    \n",
       "    This is very useful when trying to use such lists as arguments to\n",
       "    system commands.\n",
       "%%time:\n",
       "    ::\n",
       "    \n",
       "      %time [--no-raise-error]\n",
       "    \n",
       "    Time execution of a Python statement or expression.\n",
       "    \n",
       "    The CPU and wall clock times are printed, and the value of the\n",
       "    expression (if any) is returned.  Note that under Win32, system time\n",
       "    is always reported as 0, since it can not be measured.\n",
       "    \n",
       "    This function can be used both as a line and cell magic:\n",
       "    \n",
       "    - In line mode you can time a single-line statement (though multiple\n",
       "      ones can be chained with using semicolons).\n",
       "    \n",
       "    - In cell mode, you can time the cell body (a directly\n",
       "      following statement raises an error).\n",
       "    \n",
       "    This function provides very basic timing functionality. Use the timeit\n",
       "    magic for more control over the measurement.\n",
       "    \n",
       "    .. versionchanged:: 7.3\n",
       "        User variables are no longer expanded,\n",
       "        the magic line is always left unmodified.\n",
       "    \n",
       "    .. versionchanged:: 8.3\n",
       "        The time magic now correctly propagates system-exiting exceptions\n",
       "        (such as ``KeyboardInterrupt`` invoked when interrupting execution)\n",
       "        rather than just printing out the exception traceback.\n",
       "        The non-system-exception will still be caught as before.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "      In [1]: %time 2**128\n",
       "      CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "      Wall time: 0.00\n",
       "      Out[1]: 340282366920938463463374607431768211456L\n",
       "    \n",
       "      In [2]: n = 1000000\n",
       "    \n",
       "      In [3]: %time sum(range(n))\n",
       "      CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s\n",
       "      Wall time: 1.37\n",
       "      Out[3]: 499999500000L\n",
       "    \n",
       "      In [4]: %time print('hello world')\n",
       "      hello world\n",
       "      CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "      Wall time: 0.00\n",
       "    \n",
       "    .. note::\n",
       "        The time needed by Python to compile the given expression will be\n",
       "        reported if it is more than 0.1s.\n",
       "    \n",
       "        In the example below, the actual exponentiation is done by Python\n",
       "        at compilation time, so while the expression can take a noticeable\n",
       "        amount of time to compute, that time is purely due to the\n",
       "        compilation::\n",
       "    \n",
       "            In [5]: %time 3**9999;\n",
       "            CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "            Wall time: 0.00 s\n",
       "    \n",
       "            In [6]: %time 3**999999;\n",
       "            CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "            Wall time: 0.00 s\n",
       "            Compiler : 0.78 s\n",
       "    \n",
       "    options:\n",
       "      --no-raise-error  If given, don't re-raise exceptions\n",
       "%%timeit:\n",
       "    Time execution of a Python statement or expression\n",
       "    \n",
       "    **Usage, in line mode**::\n",
       "    \n",
       "      %timeit [-n<N> -r<R> [-t|-c] -q -p<P> [-o|-v <V>]] statement\n",
       "    \n",
       "    **or in cell mode**::\n",
       "    \n",
       "      %%timeit [-n<N> -r<R> [-t|-c] -q -p<P> [-o|-v <V>]] setup_code\n",
       "      code\n",
       "      code...\n",
       "    \n",
       "    Time execution of a Python statement or expression using the timeit\n",
       "    module.  This function can be used both as a line and cell magic:\n",
       "    \n",
       "    - In line mode you can time a single-line statement (though multiple\n",
       "      ones can be chained with using semicolons).\n",
       "    \n",
       "    - In cell mode, the statement in the first line is used as setup code\n",
       "      (executed but not timed) and the body of the cell is timed.  The cell\n",
       "      body has access to any variables created in the setup code.\n",
       "    \n",
       "    Options:\n",
       "    \n",
       "    -n<N>\n",
       "      Execute the given statement N times in a loop. If N is not\n",
       "      provided, N is determined so as to get sufficient accuracy.\n",
       "    \n",
       "    -r<R>\n",
       "      Number of repeats R, each consisting of N loops, and take the\n",
       "      average result.\n",
       "      Default: 7\n",
       "    \n",
       "    -t\n",
       "      Use ``time.time`` to measure the time, which is the default on Unix.\n",
       "      This function measures wall time.\n",
       "    \n",
       "    -c\n",
       "      Use ``time.clock`` to measure the time, which is the default on\n",
       "      Windows and measures wall time. On Unix, ``resource.getrusage`` is used\n",
       "      instead and returns the CPU user time.\n",
       "    \n",
       "    -p<P>\n",
       "      Use a precision of P digits to display the timing result.\n",
       "      Default: 3\n",
       "    \n",
       "    -q\n",
       "      Quiet, do not print result.\n",
       "    \n",
       "    -o\n",
       "      Return a ``TimeitResult`` that can be stored in a variable to inspect\n",
       "      the result in more details.\n",
       "    \n",
       "    -v <V>\n",
       "      Like ``-o``, but save the ``TimeitResult`` directly to variable <V>.\n",
       "    \n",
       "    .. versionchanged:: 7.3\n",
       "        User variables are no longer expanded,\n",
       "        the magic line is always left unmodified.\n",
       "    \n",
       "    Examples\n",
       "    --------\n",
       "    ::\n",
       "    \n",
       "      In [1]: %timeit pass\n",
       "      8.26 ns ± 0.12 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)\n",
       "    \n",
       "      In [2]: u = None\n",
       "    \n",
       "      In [3]: %timeit u is None\n",
       "      29.9 ns ± 0.643 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n",
       "    \n",
       "      In [4]: %timeit -r 4 u == None\n",
       "    \n",
       "      In [5]: import time\n",
       "    \n",
       "      In [6]: %timeit -n1 time.sleep(2)\n",
       "    \n",
       "    The times reported by ``%timeit`` will be slightly higher than those\n",
       "    reported by the timeit.py script when variables are accessed. This is\n",
       "    due to the fact that ``%timeit`` executes the statement in the namespace\n",
       "    of the shell, compared with timeit.py, which uses a single setup\n",
       "    statement to import function or create variables. Generally, the bias\n",
       "    does not matter as long as results from timeit.py are not mixed with\n",
       "    those from ``%timeit``.\n",
       "%%writefile:\n",
       "    ::\n",
       "    \n",
       "      %writefile [-a] filename\n",
       "    \n",
       "    Write the contents of the cell to a file.\n",
       "    \n",
       "    The file will be overwritten unless the -a (--append) flag is specified.\n",
       "    \n",
       "    positional arguments:\n",
       "      filename      file to write\n",
       "    \n",
       "    options:\n",
       "      -a, --append  Append contents of the cell to an existing file. The file will be created if it does not exist.\n",
       "\n",
       "Summary of magic functions (from %lsmagic):\n",
       "Available line magics:\n",
       "%alias  %alias_magic  %autoawait  %autocall  %automagic  %autosave  %bookmark  %cat  %cd  %clear  %code_wrap  %colors  %conda  %config  %connect_info  %cp  %debug  %dhist  %dirs  %doctest_mode  %ed  %edit  %env  %gui  %hist  %history  %killbgscripts  %ldir  %less  %lf  %lk  %ll  %load  %load_ext  %loadpy  %logoff  %logon  %logstart  %logstate  %logstop  %ls  %lsmagic  %lx  %macro  %magic  %mamba  %man  %matplotlib  %micromamba  %mkdir  %more  %mv  %notebook  %page  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2  %pip  %popd  %pprint  %precision  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  %qtconsole  %quickref  %recall  %rehashx  %reload_ext  %rep  %rerun  %reset  %reset_selective  %rm  %rmdir  %run  %save  %sc  %set_env  %store  %sx  %system  %tb  %time  %timeit  %unalias  %unload_ext  %uv  %who  %who_ls  %whos  %xdel  %xmode\n",
       "\n",
       "Available cell magics:\n",
       "%%!  %%HTML  %%SVG  %%bash  %%capture  %%code_wrap  %%debug  %%file  %%html  %%javascript  %%js  %%latex  %%markdown  %%perl  %%prun  %%pypy  %%python  %%python2  %%python3  %%ruby  %%script  %%sh  %%svg  %%sx  %%system  %%time  %%timeit  %%writefile\n",
       "\n",
       "Automagic is ON, % prefix IS NOT needed for line magics."
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 显示 所有 magic 命令的详细介绍，相当于一本魔法命令使用手册。\n",
    "%magic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "79df6c46-dcdb-4209-a293-32eb85880435",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[31mDocstring:\u001b[39m\n",
       "::\n",
       "\n",
       "  %time [--no-raise-error]\n",
       "\n",
       "Time execution of a Python statement or expression.\n",
       "\n",
       "The CPU and wall clock times are printed, and the value of the\n",
       "expression (if any) is returned.  Note that under Win32, system time\n",
       "is always reported as 0, since it can not be measured.\n",
       "\n",
       "This function can be used both as a line and cell magic:\n",
       "\n",
       "- In line mode you can time a single-line statement (though multiple\n",
       "  ones can be chained with using semicolons).\n",
       "\n",
       "- In cell mode, you can time the cell body (a directly\n",
       "  following statement raises an error).\n",
       "\n",
       "This function provides very basic timing functionality. Use the timeit\n",
       "magic for more control over the measurement.\n",
       "\n",
       ".. versionchanged:: 7.3\n",
       "    User variables are no longer expanded,\n",
       "    the magic line is always left unmodified.\n",
       "\n",
       ".. versionchanged:: 8.3\n",
       "    The time magic now correctly propagates system-exiting exceptions\n",
       "    (such as ``KeyboardInterrupt`` invoked when interrupting execution)\n",
       "    rather than just printing out the exception traceback.\n",
       "    The non-system-exception will still be caught as before.\n",
       "\n",
       "Examples\n",
       "--------\n",
       "::\n",
       "\n",
       "  In [1]: %time 2**128\n",
       "  CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "  Wall time: 0.00\n",
       "  Out[1]: 340282366920938463463374607431768211456L\n",
       "\n",
       "  In [2]: n = 1000000\n",
       "\n",
       "  In [3]: %time sum(range(n))\n",
       "  CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s\n",
       "  Wall time: 1.37\n",
       "  Out[3]: 499999500000L\n",
       "\n",
       "  In [4]: %time print('hello world')\n",
       "  hello world\n",
       "  CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "  Wall time: 0.00\n",
       "\n",
       ".. note::\n",
       "    The time needed by Python to compile the given expression will be\n",
       "    reported if it is more than 0.1s.\n",
       "\n",
       "    In the example below, the actual exponentiation is done by Python\n",
       "    at compilation time, so while the expression can take a noticeable\n",
       "    amount of time to compute, that time is purely due to the\n",
       "    compilation::\n",
       "\n",
       "        In [5]: %time 3**9999;\n",
       "        CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "        Wall time: 0.00 s\n",
       "\n",
       "        In [6]: %time 3**999999;\n",
       "        CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s\n",
       "        Wall time: 0.00 s\n",
       "        Compiler : 0.78 s\n",
       "\n",
       "options:\n",
       "  --no-raise-error  If given, don't re-raise exceptions\n",
       "\u001b[31mFile:\u001b[39m      ~/miniconda3/envs/ml/lib/python3.12/site-packages/IPython/core/magics/execution.py"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 直接查看单个命令的帮助.命令尾部 ? 显示简要帮助 ; ?? 显示源代码（如果能显示的话）\n",
    "%time?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f93f1f01-794b-4f79-a626-ee8ccb9b561c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
